【问题标题】:Redirect / Rewrite with .htaccess of an url containing :使用包含以下内容的 .htaccess 重定向/重写:
【发布时间】:2018-05-20 11:45:46
【问题描述】:

我正在尝试从 /index.php?option=com_k2&view=itemlist&task=category&id=44:pinco 重定向到 google.it

注意特殊字符:

但它似乎不起作用。

这是我尝试过的测试之一。我哪里错了?

redirect 301 /?option=com_k2&view=item&id=44:pinco http://www.google.it

【问题讨论】:

  • “我哪里错了?” - 根据您对文档中提到 “URL-path” 的含义的理解 ...
  • @CBroe:你的意思是路径应该是绝对的?
  • 还是无法解析整个查询字符串?
  • URL 的 path 组件是此处唯一需要检查的内容 - 即 index.php。如果你想根据查询字符串做任何事情,那么你需要使用 mod_rewrite (RewriteCond 检查查询字符串内容,然后是 RewriteRule 然后根据条件重定向到其他地方。)

标签: apache .htaccess redirect url-redirection http-status-code-301


【解决方案1】:

您不能使用Redirect 指令重定向查询字符串。您需要使用℅{QUERY_STRING} 变量检查查询字符串。

RewriteEngine on

RewriteCond ℅{QUERY_STRING} ^option=com_k2&view=itemlist&task=category&id=44:pinco$
RewriteRule ^index\.php$ http://google.it? [L,R]

【讨论】:

    猜你喜欢
    • 2012-05-05
    • 2011-08-18
    • 1970-01-01
    • 2015-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多