Rooturaj Pattanaik
Rooturaj Pattanaik

Reputation: 122

How to avoid htaccess redirect-rewrite loop?

My current htaccess does two simple url rewrites for two simple page. Here is the code.

RewriteEngine On
RewriteRule    ^home/?$    index.php#home    [NC,L]
RewriteRule    ^contact/?$    index.php#contact    [NC,L]

now mywebsites.com and mywebsite.com/home are the same pages. I am using the twitter bootstrap carousel to flip slide between page without actually loading them.

Unfortunately the number of facebook share on mywebsite.com/home is 2000 and on mywebsite.com/ is 29. So I want to 301 redirect mywebsite.com/ to mywebsite.com/home but that puts the htaccess into an infinite loop.

any help will be widely appreciated.

Upvotes: 0

Views: 1724

Answers (1)

Unamata Sanatarai
Unamata Sanatarai

Reputation: 6647

The following should allow for only ONE redirection.

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule .* - [L]

Does that help?

Upvotes: 1

Related Questions