Forum Moderators: phranque
I've spent 4 hours looking for this and I keep getting recursion.
Everywhere the simplest solution to force a folder to be https is:
RewriteCond %{https} =off
RewriteRule ^(.*) https://%{SERVER_NAME}/folder/$1 [R=301,L]
I installed the .htaccess inside the folder I want to force https and I don't know why but I keep getting and error saying that there were too many redirects trying to access the page.
What can I be missing?
Thanks for the help.
I also tried:
RewriteCond %{SERVER_PORT} !^443
instead of,
RewriteCond %{https} =off
And the problem persists. The redirection to https occurs but becomes recursive.
Why is that RewriteCond not working? any ideas?
Similar problem on thread [webmasterworld.com...] with infinite looping not sure if it got resolved for the original poster bu not for me..
What could be happening?
I was right. My server (Rackspace.com) was not recognizing RewriteCond %{SERVER_PORT} !^443 because it uses a different system.
From their wiki -> [cloudsites.rackspacecloud.com...]
Answer:
#Force SSL on a specific directory
RewriteEngine On
RewriteBase /
RewriteCond %{ENV:HTTPS} !on [NC]
RewriteRule ^(.*)$ https://(YOURDOMAIN)/DIRNAMEHERE/ [R,L]
Why in the world they use %{ENV:HTTPS} ?
If you want search engines to list only https URLs, then be sure to use [R=301] as you did in your initial attempts -- The Rackspace code will do a 302 by default, and search engines won't update your URLs to https as a result of that.
They appear to be dropping the requested URL-path as well, since there is no "$1" back-reference in their substitution URL.
Also, "RewriteBase /" is the default, and not needed unless you have previously set it to some other path.
Jim
I added [R=301] and the "$1" I added last night for it to work.
BTW: I am impressed with your dedication to this forum!
You "joined" it back in 2002, that is 2,785 days ago and have 21,828 posts. That is almost 8 posts a day for the last 7 years!
Congratulations and thanks so much for your incredible dedication!