如何使用htaccess将index.php请求重定向到/home
我目前正在使用这种方法如何使用htaccess将index.php请求重定向到/home,php,regex,apache,.htaccess,mod-rewrite,Php,Regex,Apache,.htaccess,Mod Rewrite,我目前正在使用这种方法 RewriteCond %{THE_REQUEST} ^.*/index.php RewriteRule ^(.*)index.php$ http://www.mysite.com/home$1 [R=301,L] 这是可行的,但是有没有任何方法可以在不手动输入的情况下获取web根目录。以便自动替换“”零件。这样我就可以在本地服务器和生产环境中使用它,而无需进行任何更改 是,请确定您可以使用: RewriteCond %{THE_REQUEST} /index\.php
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.mysite.com/home$1 [R=301,L]
这是可行的,但是有没有任何方法可以在不手动输入的情况下获取web根目录。以便自动替换“”零件。这样我就可以在本地服务器和生产环境中使用它,而无需进行任何更改 是,请确定您可以使用:
RewriteCond %{THE_REQUEST} /index\.php [NC
RewriteRule ^(.*)index\.php$ /home$1 [R=301,L,NC]
只有当您的规则重定向到外部URL时,目标URI才需要http://的完整站点地址,但在本例中,您不是