[英]URL rewriting: Change mydomain.com/index.php to mydomain.com/home
I am working with PHP
and I want to change this url mydomain.com/index.php
to this mydomain.com/home
so wrote the following code: 我正在使用
PHP
并且想将此URL mydomain.com/index.php
更改为mydomain.com/home
因此编写了以下代码:
RewriteEngine on
RewriteRule home index.php
When I go to mydomain.com/home
it works but when I go to mydomain.com/index.php
the url does not change to mydomain.com/home
当我转到
mydomain.com/home
它可以工作,但是当我转到mydomain.com/index.php
,URL不会更改为mydomain.com/home
How can I solve this problem, please ? 请问如何解决这个问题?
Try : 尝试:
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
Example 例
RewriteEngine on
RewriteBase /
RewriteRule index.php http://example.com/home [L,R=301]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.