0

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.

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.

4

1 回答 1

0

RewriteRule不匹配查询,只是路径文件/目录名称。

用于RewriteCond %{QUERY_STRING}处理查询。

于 2012-11-27T21:32:09.313 回答