Forum Moderators: phranque

Message Too Old, No Replies

re-direct ALL traffic to main page?

         

microcars

6:48 am on Mar 27, 2004 (gmt 0)

10+ Year Member


is it as simple as this in my .htaccess file:
RewriteEngine on
RewriteRule ^/(.+) http://example.com/$1 [R,L]

or would it be something else?

I will need to temporarily direct ANY requests for ANY pages on a particular domain to the main page.

Of course, I could just try it couldn't I? but I'm a-scared!

:-/

Birdman

11:53 am on Mar 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Pretty close, except you are redirecting right back to the same page by using the back-reference($1). The back-reference captures whatever is in the parens in the left side of the rule. In your case you don't need the parens. You could actually use mod_alias' RedirectMatch instead.

No reason to be scared to try something as long as you are ready to quickly put the old .htaccess file back if you get the dreaded server error.

RewriteEngine on
RewriteRule ^.*$ / [R=302,L]

or mod_alias:

RedirectMatch ^/.*$ [yoursite.com...]

microcars

5:11 pm on Apr 1, 2004 (gmt 0)

10+ Year Member



hmmm, tried both examples.

First one did not seem to do anything.

Second one worked perfectly on Safari browswer but Mozilla and IE just did an infinite loop of re-directs.

yes, I uploaded as text, not binary. Perhaps I did something else wrong.

oh, well, it was for an April Fools prank, no big deal.