默認的URL。domain.com/contact.php
重寫URL為。<代碼>domain.com/contactus代碼>
當我要輸入默認的URL到。domain.com/contact.php,它應該重定向(打開)到domain.com/contactus。
我試過
RewriteRule ^contactus$ contact.php [L] 。
RewriteRule contact.php contactus [NC,R=301,L] 。
uj5u.com熱心網友回復:
你需要一個重定向規則來強制在瀏覽器中使用新的URI,一個重寫規則來轉發新的URI到php檔案:
RewriteEngine On
#重定向規則
RewriteCond %{THE_REQUEST} s/contact.php[?s] [NC)
RewriteRule ^ /contactus? [L,R=301]
#重寫規則。
RewriteRule ^contactus/?$ contact.php [L,NC)
?在目標URI中會洗掉現有的查詢字串。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/327105.html
標籤:
