【发布时间】:2010-11-08 17:14:54
【问题描述】:
我正在使用 Isapi Rewrite 3(IIS 的 mod 重写克隆)并尝试根据查询字符串重写 URL - 然后在重写中传递该查询字符串的一部分。
如果我输入这样的网址:/test/home.cfm?page=default&arbitraryExtraArg=123
我希望将其重写为:/test/index.cfm?page=home&arbitraryExtraArg=123
我有以下条件/规则:
RewriteCond %{QUERY_STRING} ^page=default(.*)$ [I]
RewriteRule ^/test/home.cfm$ /test/index.cfm?page=home%1 [I,R=301]
但是永远不会传递额外的查询字符串变量。 %1 似乎是空白的。
这是如何从 RewriteCond 引用模式匹配,对吧?
我在这里错过了什么?
谢谢!
编辑:在我看来,RewriteCond 完全被忽略了。这是我的日志文件的样子:
[snip] (2) init rewrite engine with requested uri /test/home.cfm?page=default
[snip] (1) Htaccess process request C:\Inetpub\wwwroot\dev\IsapiRewrite\httpd.conf
[snip] (3) applying pattern '^/test/home\.cfm$' to uri '/test/home.cfm'
[snip] (1) escaping /test/index.cfm?page=home
[snip] (2) explicitly forcing redirect with http://www.devsite.com/test/index.cfm?page=home
[snip] (2) internal redirect with /test/home.cfm?page=default [INTERNAL REDIRECT]
[snip] (2) init rewrite engine with requested uri /test/index.cfm?page=home
[snip] (1) Htaccess process request C:\Inetpub\wwwroot\dev\IsapiRewrite\httpd.conf
[snip] (3) applying pattern '^/test/home\.cfm$' to uri '/test/index.cfm'
那里应该提到 RewriteCond 模式检查吗?
【问题讨论】:
-
但是规则被应用了?
-
是的,没错。我最终在 /test/index.cfm?page=home
-
那么
/test/home.cfm?page=default的初始请求呢?还是您一直在测试/test/index.cfm?page=home?如果是这样,您可能误解了 URL 重写的工作原理。他们只是重写请求的 URI! -
糟糕!我刚刚包括了重定向后的日志记录。现已添加完整的日志详细信息
标签: mod-rewrite query-string isapi-rewrite