【发布时间】:2015-11-30 14:08:21
【问题描述】:
我在我的 httpd-apache 2.2 文件中使用了与以下类似的代码
<Location /local/*/*/*>
setHandler dispatcher-handler
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*.*.* [NC]
RewriteRule ^/?(.*)/(.*)/(.*)$ www.dns.com/product.html?state=$1&city=$2&product=$3 [R]
</Location>
当我在浏览器中给出 URL-www.dns.com/local/1/2/3
在日志中,查询中断如下:
state=opt/apache/httpserver/htdocs/local/1&city=2&product=3
我如何编码 httpd 文件,以便 state 必须只采用 1 而不是采用完整的“文档根”路径和“本地”?
理想情况下我想要state=1、city=2、product=3
我怎样才能实现这个功能?
【问题讨论】:
-
RewriteRule仅匹配请求的 URI 的路径部分。如果要检查查询字符串的内容,则需要使用RewriteCond(有关详细信息,请参阅文档。)
标签: apache query-string httpd.conf