Hello,
Can anyone help me make the correct .htaccess rules in order to switch between https and http depending on the accessed file or folder.
my .htaccess looks something like this:
RewriteEngine on
#enforce www
RewriteCond %{HTTP_HOST} !^www.site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301]
# Turn https on only for the links: https://www.site.com/thefolder/ and https://www.site.com/thelink
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} (thefolder/|thelink)
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
# Turn https off for everything but the links: https://www.site.com/thefolder/ and https://www.site.com/thelink
RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !(thefolder/|thelink)
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^key/a-link\\z /a-link [NC,L,R=301]
RewriteRule ^a-link\\z index.php?key=a-link [NC,L]
...
[B]RewriteRule ^key/thelink\\z /thelink [NC,L,R=301]
RewriteRule ^thelink\\z index.php?key=thelink [NC,L][/B]
- When I go to: [noparse]http://www.site.com/thelink[/noparse] it changes to: [noparse]http://www.site.com/index.php?key=thelink[/noparse] instead of [noparse]https://www.site.com/thelink[/noparse]
- When I go to: [noparse]http://www.site.com/thefolder/[/noparse] it changes goes to 404 not found…
(the only thing that works is that all other pages but “thelink” when accessed with https switch to http)
What am i doing wrong? How can I make it work ?
Thank you in advance for your help!