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