Apache 断开查询字符串并检索值
我在我的httpd apache 2.2文件中使用了如下类似的代码Apache 断开查询字符串并检索值,apache,query-string,httpd.conf,Apache,Query String,Httpd.conf,我在我的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 /local/*/*/*>
setHandler dispatcher-handler
RewriteEngine On
RewriteCond %{REQUEST_URI} ^.*.*.* [NC]
RewriteRule ^/?(.*)/(.*)/(.*)$ www.dns.com/product.html?state=$1&city=$2&product=$3 [R]
</Location>
如何对httpd文件进行编码,使状态
只能采用1
而不是采用完整的“文档根目录”路径和“本地”路径
理想情况下,我想要state=1
,city=2
,product=3
如何实现此功能?问题是您的目标从“www.dns.com”开始,它缺少作为标准编译器URL的协议部分“http://”。您可以通过将其更改为
RewriteRule ^/?(.*)/(.*)/(.*)$ http://www.dns.com/product.html?state=$1&city=$2&product=$3 [R]
或者使用当前主机相对路径,如下所示:
RewriteRule ^/?(.*)/(.*)/(.*)$ /product.html?state=$1&city=$2&product=$3 [R]
RewriteRule
仅与请求URI的路径组件匹配。如果要检查查询字符串的内容,需要使用RewriteCond
(有关详细信息,请参阅文档)。我已尝试使用RewriteRule^/?(.*)/(.*)/(.*)/(.*)$[R]还有同样的问题…………如果我给www.dns.com/local/1/2/3……state=opt/apache/httpserver/htdocs/local/1&city=2&product=3……。我想去掉“opt/apache/httpserver/htdocs/local”,我试过用RewriteRule^/?(*)/(*)/(*)/(*))$[R]还有同样的问题…….如果我给www.dns.com/local/1/2/3…….state=opt/apache/httpserver/htdocs/local/1&city=2&product=3…….我想摆脱“opt/apache/httpserver/htdocs/local”,请再次阅读我的答案。我按照您提到的方式给出规则。我的评论中没有显示“http://”。我给出了DNS和“http://”-您提到的第二个解决方案也是如此。-------state=opt/apache/httpserver/htdocs/publish-9001/local/1&city=2&product=3Ah ok。对不起。您确定删除了以前的规则吗?
RewriteRule ^/?(.*)/(.*)/(.*)$ /product.html?state=$1&city=$2&product=$3 [R]