Html 如何使用htaccess将website.com/和website.com/index.php重定向到另一个页面
我可以将Html 如何使用htaccess将website.com/和website.com/index.php重定向到另一个页面,html,apache,.htaccess,url-rewriting,Html,Apache,.htaccess,Url Rewriting,我可以将website.com/index.php重定向到website.com/home但我找不到方法将website.com重定向到website.com/home 我尝试过重写规则^/$/home[R=301],但它没有任何作用。试试这个 RewriteEngine on RewriteBase / RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC] RewriteRule .* http://www.website.com/hom
website.com/index.php
重定向到website.com/home
但我找不到方法将website.com
重定向到website.com/home
我尝试过重写规则^/$/home[R=301],但它没有任何作用。试试这个
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC]
RewriteRule .* http://www.website.com/home [R=301,L]
此规则将www.website.com重定向到www.website.com/home
或者将其添加到.htaccess
RewriteRule ^/?$ /home [R=301,L]
一条规则可以处理两个重定向:
RewriteRule ^/?(index\.php)?$ /home [NC,L,R=301]