Jump to content

Problem with redirect.


Err
 Share

Recommended Posts

I'm using this .htaccess code:

RedirectMatch 302 ^/ /index2.html

The above code is suppose to redirect all pages on a site to /index2.html, but when I add it to my .htaccess file I get as far as getting the index2.html url loaded into my address bar, but then Firefox says:

The page isn't redirecting properlyFirefox has detected that the server is redirecting the request for this address in a way that will never complete.
I figured that when I use that code, it is trying to redirect to the index2.html page, but then that page itself is on my site so it tries to redirect again back into index2.html page, of course this is causing a loop. Any way I can get out of this? Do I need to have a certain setting enabled? Am I missing something? When I redirect single pages into /index2.html it works fine, so I know redirecting pages are enabled.Edit: Edited for more clarity.
Link to comment
Share on other sites

  • 3 months later...

Thanks for your reply. I finally figured it out. For anyone that wants to know what I did, look at the code below:Redirect everyone, and every page, but you to an alternate page on your server.

RewriteEngine OnRewriteBase /RewriteCond %{REMOTE_HOST} !^00\.00\.00\.00RewriteCond %{REQUEST_URI} !^/index2\.html$RewriteCond %{REQUEST_URI} !/\$RewriteRule .* /index2.html [R=302,L]

On the first "RewriteCond" put in your IP address, on the second put the page you want to redirect too, on the third the folders/link you want to redirect ( have a / on mine for all the files). On "RewriteRule" again put the page you want to redirect too.I added the 4th line in the code. Otherwise the browser will try to redirect the page you wanted to redirect too, causing a loop that doesn't redirect properly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...