[英]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.