[英]How to redirect requests for index.php to /home with htaccess
I'm currently using this method 我目前正在使用这种方法
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.mysite.com/home$1 [R=301,L]
Which works, but is there any way of getting the web root directory without entering it manually. 哪个可行,但是有什么方法可以获取Web根目录,而无需手动输入。 So that the " http://www.mysite.com " part is replaced automatically. 以便自动替换“ http://www.mysite.com ”部分。 Just so that I can use this on my local server aswell as production without making changes. 这样我就可以在本地服务器以及生产环境中使用它,而无需进行更改。
Yes sure you can use: 是的,您可以使用:
RewriteCond %{THE_REQUEST} /index\.php [NC
RewriteRule ^(.*)index\.php$ /home$1 [R=301,L,NC]
target URI needs full site address with http://
ONLY if your rule is redirecting to an outside URL but in this case you aren't. 仅当您的规则重定向到外部URL时,目标URI才需要带有http://
完整站点地址,但在这种情况下,则不是。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.