views:

42

answers:

1

Hi

I have the following in a .htaccess file

redirect 301 /page.php http://domain.com/page

Which works fine and as expected.

I want to be able to redirect the following

http://domain2.com/page.php to http://domain2.com/page
or
http://domain3.com/page.php to http://domain3.com/page
or
http://domain4.com/page.php to http://domain4.com/page

So basically whatever the domain name is, I want to redirect to it. But the catch is I want to use a 301 redirect. Is this even possible ? Or should I be using RewriteCond and RewriteRule ?

+2  A: 

I think just RewriteRule would be sufficient:

RewriteRule ^/page\.php$ /page [R=301,L]

This will cause any request for page.php to be redirected to page on the same domain. The R=301 causes a 301 redirect to be used.

Sean Carpenter
Great thanks, what does the L flag mean ?
neilc
The "L" stops additional rules from being processed. I'm not sure if it is necessary when using "R" but it doesn't hurt.
Sean Carpenter