Forum Moderators: phranque

Message Too Old, No Replies

.htaccess works in ff and safari, fails in ie and chrome

301 redirect

         

eddierosenthal

5:15 pm on Mar 27, 2012 (gmt 0)

10+ Year Member



I am working with a website and have this for his .htaccess file ( including wp pieces)
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mcp-live\.com$ [NC]
RewriteRule ^(.*)$ http://www.mcp-live.com/$1 [R=301,L]


# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress


the url is www.mcp-live.com
but if you request mcp-live.com it fails in ie9 and google chrome, works ok in firefox and safari.
if i use a "view http path tool" i see error maximum number of redirections exceeded.
The domain registrar is homestead, the host is hostgator. Any suggestions on what to do about this? thanks in advance

g1smd

7:13 pm on Mar 27, 2012 (gmt 0)

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



Change this:
RewriteRule ^index\.php$ - [L]

to this:
RewriteCond %{REQUEST_URI} !^/index\.php$


Get rid of these three lines:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /


and this line:

</IfModule>


Add a blank line after every RewriteRule so you can clearly see each separate ruleset.


The notion that a rule works in one browser but not another is false. The code is run entirely inside the server. The difference in observed function is caused by each of your browsers having different cached data. Clear your browser cache before each test.

eddierosenthal

8:30 pm on Mar 27, 2012 (gmt 0)

10+ Year Member



seems to work now. didn't think the browsers were at fault, just had the symptoms of it. there ought to be a course in .htaccess somewhere... thanks for your reply! edward

lucy24

10:23 pm on Mar 27, 2012 (gmt 0)

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



there ought to be a course in .htaccess somewhere...

There is :) Go to [httpd.apache.org...] and explore. Or proceed directly to [httpd.apache.org...] but do not try to learn it all at once!

Oh, and just to make sure: When g1 says to get rid of
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

and
</IfModule>

He means:
#1 get rid of all occurrences of "IfModule" -- not just for mod_rewrite but for any other module you'll be working with. These envelopes are built into your generic htaccess, but you don't need them once you are in your real, individual htaccess for your real, individual site. Either you have mod_rewrite or (shudder!) you don't, and you should code accordingly.
#2 Get rid of all occurrences of RewriteBase / because they are rarely needed in htaccess.
#3 Keep the first occurrence of RewriteEngine On. You need to say it once in each htaccess that uses mod_rewrite, and it has to come before any rewrites.