开发者

http 301 redirect from htaccess to domain host

开发者 https://www.devze.com 2022-12-23 14:21 出处:网络
I have the following in a .htaccess file redirect 301 /page.php http://domain.com/page Which works fine and as expected.

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 r开发者_StackOverflow社区edirect 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 ?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号