0
我有一個奇怪的301 Redirect
問題。301重定向不能按預期工作
我用下面的規則
Redirect 301 /catalog/index.php?target=news /news
奇怪的是,當我訪問/catalog/index.php?target=news
我重定向到:/catalog/?target=news
我有一個奇怪的301 Redirect
問題。301重定向不能按預期工作
我用下面的規則
Redirect 301 /catalog/index.php?target=news /news
奇怪的是,當我訪問/catalog/index.php?target=news
我重定向到:/catalog/?target=news
查詢字符串不是URI的一部分Redirect
模式被匹配。它已被刪除,因此您無法在您的聲明中嘗試與之匹配。你需要使用mod_rewrite和對%{QUERY_STRING}
變量相匹配的條件:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^target=news$
RewriteRule ^/?catalog/(index\.php)?$ /news? [L,R=301]
這些規則應該在你的文檔根htaccess的文件。
嘗試URL編碼重定向URL - /「/ news」可能會導致一些奇怪的行爲。 – Ripside 2013-03-01 14:49:11
hm ...我不知道如何在htaccess中編碼 - 你能給我一個例子嗎? – user608207 2013-03-01 14:57:22
我認爲你的查詢字符串值中的最後一個斜槓是什麼讓你失望。試試這個 - /catalog/index.php?target=news+%2Fnews – Ripside 2013-03-01 15:16:06