Redirigir solo una carpeta a HTTPS, todas las demás a HTTP

I apologize in advance for asking something that's been answered several times on SO, but I haven't been able to modify any of the answers to work for this case.

I have a /secure/ folder that I need to redirect to HTTPS. Everything outside of that folder should be redirected to HTTP.

I plan on using absolute links for navigation through my site, but I need to guarantee that the pages in the /secure/ folder are only viewable over HTTPS. For the other pages it doesn't really matter, but I'd prefer them only viewable over HTTP because I'm on shared hosting and the server is already slow as it is.

Muchas gracias!

preguntado el 10 de marzo de 12 a las 00:03

Could you just modify the .htaccess document for the secure/ directory? That way you don't have to worry about a general-purpose .htaccess that handles different directories differently. -

1 Respuestas

Adapted an example on this page consulta en esta página. See if the following works for you.

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} secure 
RewriteRule ^(.*)$$1 [R,L]

respondido 10 mar '12, 00:03

Thank you very much, that worked like a champ! I tried several ways to automatically redirect to HTTP if a page is visited outside of the /secure/ folder, but I couldn't get it to work. It shouldn't matter though, if they end up browsing the rest of the site in HTTPS, that's fine. - Programador aspirante novato

"Browsing the rest of the site in HTTPS" is fine except that you can risk have duplicate content indexed by Google which isn't fine if you value your organic rankings - hobailey

@bloudraak : this not work to redirect other page to HTTP.for example: not redirect to - MJH

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.