簡體   English   中英

如何使用htaccess將index.php的請求重定向到/ home

[英]How to redirect requests for index.php to /home with htaccess

我目前正在使用這種方法

RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.mysite.com/home$1 [R=301,L]

哪個可行,但是有什么方法可以獲取Web根目錄,而無需手動輸入。 以便自動替換“ http://www.mysite.com ”部分。 這樣我就可以在本地服務器以及生產環境中使用它,而無需進行更改。

是的,您可以使用:

RewriteCond %{THE_REQUEST} /index\.php [NC
RewriteRule ^(.*)index\.php$ /home$1 [R=301,L,NC]

僅當您的規則重定向到外部URL時,目標URI才需要帶有http://完整站點地址,但在這種情況下,則不是。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM