[英]htaccess redirect where index.php? exists
我一直發現htaccess是一件卑鄙的事情:)
我有一個由CMS支持的網站,該網站的URL中包含index.php。 我通常的htaccess足以將其刪除。
但是,從歷史上看,該站點的URL一直處於離線狀態http://domain.org/index.php?/resources/name-index/a/steven
但是,此URL不再存在,而應指向http://domain.org/pages/steven
我添加了其他重定向
RewriteRule ^resources/name-index/a/steven http://domain.org/pages/steven
但是,當我點擊http://domain.org/index.php?/resources/name-index/a/steven時,我們會得到一個404,但如果我們點擊http://domain.org/resources/name-index / a / steven會按照您期望的那樣重寫到新頁面。
忍不住想了嗎? 網址中的規則正在破壞該規則,或者事實是index.php被上面的另一個規則刪除了(不會以為這會很重要)。
歡迎提出建議。
將此代碼放在htaccess的開頭(應位於根文件夾中)
RewriteEngine On
RewriteCond %{QUERY_STRING} ^/resources/name-index/a/steven$ [NC]
RewriteRule ^index\.php$ /pages/steven? [R=301,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.