繁体   English   中英

网址重写:将mydomain.com/index.php更改为mydomain.com/home

[英]URL rewriting: Change mydomain.com/index.php to mydomain.com/home

我正在使用PHP并且想将此URL mydomain.com/index.php更改为mydomain.com/home因此编写了以下代码:

RewriteEngine on
RewriteRule home index.php

当我转到mydomain.com/home它可以工作,但是当我转到mydomain.com/index.php ,URL不会更改为mydomain.com/home

请问如何解决这个问题?

尝试:

RewriteEngine on
#externally redirect "/index.php" to "/home"
RewriteCond %{THE_REQUEST} \s/index\.php
RewriteRule ^ /home [L,R]
#internally map "/home" back to "/index.php"
RewriteRule home index.php

RewriteEngine on
RewriteBase /
RewriteRule index.php http://example.com/home [L,R=301]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM