2010-03-22 90 views
0

在.htaccess文件HTTP 301 htaccess的重定向到域名主機

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

的正常工作和預期,我有以下。

我希望能夠重定向以下

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 

所以基本上任何域名是的,我想重定向到它。但問題是我想使用301重定向。這甚至有可能嗎?或者我應該使用RewriteCond和RewriteRule?

回答

2

我覺得只是重寫規則就足夠了:

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

這將導致page.php的任何請求重定向到page在同一個域。 R=301會導致使用301重定向。

+0

非常感謝,L旗是什麼意思? – 32423hjh32423 2010-03-23 08:53:44

+0

「L」停止處理其他規則。我不確定在使用「R」時是否有必要,但不會造成傷害。 – 2010-03-23 12:27:07