Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm attempting to setup redirection for a couple of root domains.

Firstly, here is the code in my httpd-vhosts.conf file:

<VirtualHost *:80>

ServerAdmin ****@example.com
ServerName example.com
ServerAlias example2.com

RewriteEngine On
RewriteCond %{HTTP_HOST} !^192\.168\.0\.1$    # This is our WAN IP
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.%{HTTP_HOST}/$1 [L,R,NE]

</VirtualHost>

What this does is redirect the root domain of example.com or example2.com or any host other than www to www.example(2).com

The part I'm having a problem with is the RewriteRule itself. the $1 is supposed to match the pattern of the RewriteRule and add it in the substitution. For example: "http://example.com/test.html" should rewrite to "http://www.example.com/test.html"

It works in all modern browsers like it's supposed to except for IE8 or IE9 (I didn't test other IE versions).

In IE, this works: "http://example.com" to "http://www.example.com"

In IE, this does not work: "http://example.com/test.html" to "http://www.example.com/test.html"

Does anyone have an explanation for this behavior?

I hope I've explained it well enough.

Thank you.

share|improve this question
1  
Define "does not work". mod_rewrite doesn't care what browser you use unless there's a RewriteCond on user agent or something. –  ceejayoz Nov 5 '11 at 2:40
    
I thought I clarified pretty well in the OP. Any modern browser other than IE this works: example.com/test.html to www.example.com/test.html but in IE that doesn't work. It will not rewrite the www part. However If I don't put anything after the slash then it does work, example: example.com to www.example.com works in every browser including IE. There is no user agent rewrite conditions. IE simply fails to follow the 301 redirect properly. –  Ryan Mortier Nov 5 '11 at 16:55
    
The .htaccess rules you've provided cannot cause IE to do something different than another browser. Something else is going on. –  ceejayoz Nov 5 '11 at 17:00
    
@ceejayoz: this is not a .htaccess but you're right: it can't be a browser problem unless morrty didn't give the whole rewrite rules. –  Olivier Pons Nov 5 '11 at 21:19
    
@Olivier Pons: I assure you that the only thing I changed was our WAN IP address in the OP and the root domain to example.com, everything else is in its full. I guess I'll just deal with this behaviour. It's just weird that IE is the only browser doing this. I too doubt that anything I'm doing is affecting the browser but perhaps IE has always had this behaviour? –  Ryan Mortier Nov 7 '11 at 14:23

1 Answer 1

Placing this code in htaccess fixed a similar for me:

BrowserMatch "MSIE [2-8]" nokeepalive downgrade-1.0 force-response-1.0
share|improve this answer
    
worked for me! thanks –  Red Cricket Feb 1 at 8:45
    
Resolved my issue with IE 8! –  jerrygarciuh Sep 3 at 0:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.