簡體   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