Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用htaccess将index.php请求重定向到/home_Php_Regex_Apache_.htaccess_Mod Rewrite - Fatal编程技术网

如何使用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://的完整站点地址,但在本例中,您不是