fixnode
fixnode

Reputation: 107

Google Chrome and apache .htaccess redirect loop error

I have a problem that only affects google chrome. I have two subdirectories secure.fixnode.ca and storage.fixnode.ca, both of these sudirectories need to use https protocol.

The error I get in Google Chrome is: "Redirect Loop Error, Too Many Redirects"

storage.fixnode.ca works OK in google chrome, but for some reason secure.fixnode.ca does NOT.

Also BOTH subdirectories work great in every other browser (IE, FF, Safari).

below is my .htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^fixnode\.ca$ [NC]
RewriteRule ^.*$ http://www.fixnode.ca%{REQUEST_URI} [R=permanent,L]

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(secure|storage)\. [NC]
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

# END OF CHANGE
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php

ErrorDocument 401 /?loc=401error.php
ErrorDocument 404 /?loc=404error.php

Options -Indexes

The line that is giveing me trouble is:

RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

it seems that google chrome sees apache https redirects as a redirect error.

does anyone know if I can do this any other way that will work in google chrome and other browsers?

Any help is appreciated

Thanks, Phillip K

Upvotes: 1

Views: 2173

Answers (1)

kjetilh
kjetilh

Reputation: 4976

Judging from your situation it seems your https redirect goes into an infinite redirect loop. I've reason to believe the %{HTTPS} variable isn't as stable is it should be (I've seen other people have had problems with this).

Try to change the %{HTTPS} condition from:

RewriteCond %{HTTPS} off

to:

# If not port 443 (https) then this condition should match
RewriteCond %{SERVER_PORT} !^443$

Alernatives are:

RewriteCond %{SERVER_PORT} ^80$

and..

RewriteCond %{REQUEST_SCHEME} ^http$

Upvotes: 1

Related Questions