[英]How to redirect website.com/ and website.com/index.php to another page with htaccess
I can redirect website.com/index.php
to website.com/home
but I can't find a way to redirect website.com
to website.com/home
我可以将
website.com/index.php
重定向到website.com/home
但我找不到将website.com
重定向到website.com/home
I have tried RewriteRule ^/$ /home [R=301]
but it does nothing. 我试过
RewriteRule ^/$ /home [R=301]
但它什么也没做。
Try this 试试这个
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC]
RewriteRule .* http://www.website.com/home [R=301,L]
This rule redirects www.website.com to www.website.com/home 此规则将www.website.com重定向到www.website.com/home
Or add this to your .htaccess 或者将此添加到.htaccess
RewriteRule ^/?$ /home [R=301,L]
单个规则可以处理两个重定向:
RewriteRule ^/?(index\.php)?$ /home [NC,L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.