首页 文章

重写条件没有被踢 - 基于查询字符串的存在的Apache mod-rewrite -

提问于
浏览
2

我有一个要求,如果一个链接有一个特定的querystring参数,那么它应该被拦截并重定向到另一个url我的当前配置看起来像这样

<IfModule rewrite_module>
RewriteEngine On
RewriteLog /cfp/apps/t/ts/x/logs/mod_rewrite.log
RewriteLogLevel 9
RewriteCond %{QUERY_STRING} /link_source/
RewriteRule (link_source=email) http://dev1.domain.net:12080/m [R]
</IfModule>

我的测试网址是这样的

http://dev1.domain.net/web/messages/7029?link_source=email

我希望这个url被这个规则捕获(因为link_source作为查询字符串存在)并重定向到新的url但是这似乎没有发生

在重写日志中,这就是我所看到的

102.2.81.95 - - [25/Jun/2014:13:41:18 --0400] [devash-ecfpwb01.svr.us.jpmchase.net/sid#d625588][rid#d7aec60/initial] (2) init rewrit
e engine with requested uri /a/messages/7029
102.2.81.95 - - [25/Jun/2014:13:41:18 --0400] [devash-ecfpwb01.svr.us.jpmchase.net/sid#d625588][rid#d7aec60/initial] (3) applying pa
ttern '(link_source=email)' to uri '/a/messages/7029'
102.2.81.95 - - [25/Jun/2014:13:41:18 --0400] [devash-ecfpwb01.svr.us.jpmchase.net/sid#d625588][rid#d7aec60/initial] (1) pass through /a/messages/7029

为什么这个规则不会生效,而且从日志中打印url减去请求参数 . 是否有办法在请求中启用查询参数的记录 .

请帮忙

1 回答

  • 0

    语法不太正确 . 将您的情况和规则改为:

    RewriteCond %{QUERY_STRING} link_source=email
    RewriteRule ^ http://dev1.domain.net:12080/m?
    

相关问题