Forum Moderators: phranque

Message Too Old, No Replies

.htaccess redirect not working for IE Browser

         

optize

3:51 am on Apr 15, 2012 (gmt 0)

10+ Year Member



I have the strangest problem....

RewriteEngine on

# Automatically redirect back to http for anything not login.php
RewriteCond %{REQUEST_URI} !^/login.php [NC]
RewriteCond %{REQUEST_URI} ^/ [NC]
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]

Pretty simple, if someone goes to [example.com,...] it redirects them to http://www.example.com

This works on all browsers except Internet Explorer, which stays on https.

What am I missing here? Does IE need a special flag in order to get this to work?

[edited by: incrediBILL at 4:11 am (utc) on Apr 15, 2012]
[edit reason] changed to example.com to fix links [/edit]

enigma1

2:07 pm on Apr 16, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Switch off keepalive as a test and retry with IE. See if it works.

You update your system from Microsoft right?

optize

5:01 pm on Apr 16, 2012 (gmt 0)

10+ Year Member



Turned off keepalive, still not redirecting.

This is a Windows 7 box with updates patched.

Can you verify this .htaccess works on your Apache server with IE?

lucy24

10:13 pm on Apr 16, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Next test: comment-out the line about Port 80.

Next test: remove the opening slash in your other two conditions:

RewriteCond %{REQUEST_URI} !^login.php [NC]
RewriteCond %{REQUEST_URI} .

(there is, ahem, no need to specify the case of a slash :))

The rules governing the presence or absence of a leading slash are arcane and mysterious and, well, let's deal with all possibilities.

Does the problem happen with all versions of MSIE or only in a certain number range?

optize

10:31 pm on Apr 16, 2012 (gmt 0)

10+ Year Member



I can't remove the port 80 line as it'll create a redirect loop.

I removed the slash, so my htaccess looks like:


RewriteCond %{REQUEST_URI} !^login.php [NC]
RewriteCond %{REQUEST_URI} ^. [NC]
RewriteCond %{SERVER_PORT} !^80$
RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]


It's still not redirecting, I'm not sure if all versions.

enigma1

9:26 am on Apr 17, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you verify this .htaccess works on your Apache server with IE?

Yes it does. Can you check your ssl.conf, do you have the IE environment setup in it?

BrowserMatch ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

optize

9:51 pm on Apr 17, 2012 (gmt 0)

10+ Year Member



I feel retarded, I found the problem..

This website is in a load balanced cluster, sadly one of the Apache web servers behind the cluster didn't have AllowOverride turned on, causing it to ignore .htaccess files.

Thanks for your help!