简体   繁体   English

Apache htaccess重写规则不匹配

[英]Apache htaccess rewrite rule not matching

I am attempting to match a URL like 我正在尝试匹配如下网址

http://www.example.org/?h=b1c60d1bf7c7119fef9fc726068e1418166.xml

or 要么

?h=b1c60d1bf7c7119fef9fc726068e1418166.jsonp&callback=testing

and re-write it like this: 然后像这样重写它:

?h=b1c60d1bf7c7119fef9fc726068e1418166&output=true&format=true&data_type=xml

or 要么

?h=b1c60d1bf7c7119fef9fc726068e1418166&output=true&format=true&data_type=jsonp&callback=testing

Here is the .htaccess file with the regex I came up with. 这是我想到的带有正则表达式的.htaccess文件。

RewriteEngine On

RewriteBase /
RewriteRule ^/?\?h=([a-z0-9]+)\.(xml|json|jsonp|rss)(\&callback=[a-z_0-9]+)?$ ?h=$1&output=true&format=true&data_type=$2&callback=$3 [L,NC,QSA]

Any ideas why this isn't matching? 有什么想法为什么不匹配? I've tested this in the server environment and on http://htaccess.madewithlove.be/ with no luck. 我已经在服务器环境中和http://htaccess.madewithlove.be/上对此进行了测试,但没有运气。

RewriteRule does not match query, just path an file/directory name. RewriteRule与查询不匹配,仅路径文件/目录名称。

Use RewriteCond %{QUERY_STRING} to work with query. 使用RewriteCond %{QUERY_STRING}处理查询。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM