Justinas
Justinas

Reputation: 43441

.htaccess not working only with internet explorer

i have site, that has to rewrite site.ru and www.site.ru to www,site.ru/ru_RU.

I can't access any Apache config files. In htaccess:

Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^site.ru$
RewriteRule (.*) http://www.site.ru/ru_RU [QSA]
RewriteCond %{HTTP_HOST} ^www.site.ru$
RewriteRule (.*) http://www.site.ru/ru_RU [QSA]

RewriteCond %{REQUEST_URI} ^/news
RewriteRule (.*) /news [QSA]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
</IfModule>

It's working in firefox or chrome, but in IE i get "this page can't be displayed". Tested on IE10 and IE8 (not compatibility view) on few computers.

If i write some junk in .htacess, i get 500 error in IE. Without .htaccess site loads ok, but i need it to rewrite url. Any ideas how to fix it?

Upvotes: 2

Views: 1407

Answers (2)

eXaminator
eXaminator

Reputation: 353

I can't test it now, but here is my guess: I think http_host ONLY contains the host part, not the uri. So you end up with an endless loop as www.site.ru is will always match again after your rewrite.

You will need another rule that checks if the uri is empty. Like this (untested):

RewriteCond %{REQUEST_URI} ^$
RewriteRule (.*) /ru_RU [QSA]

You might need another condition for the case that the uri contains a slash.

Upvotes: 0

anubhava
anubhava

Reputation: 784958

Your flags are all wrong. Modify your rules to this:

Options +FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine on

RewriteCond %{HTTP_HOST} ^site\.ru$ [NC]
RewriteRule ^ http://www.site.ru/ru_RU [L,R]

RewriteCond %{HTTP_HOST} ^www\.site\.ru$ [NC]
RewriteRule !ru_RU /ru_RU [NC,L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?page=$1 [L,QSA]

</IfModule>

Reference: Apache mod_rewrite Introduction

Upvotes: 1

Related Questions