mod rewrite Rule for Image + String to Imagefolder Rewrite
I have got some images on my server, which were always generated on the fly and requested right here:
http://www.mydomain.com/en/images.png?domain=test.com
They are now cached in
http://www.mydomain.com/images/test.com.png
I tried the following rule in my htacce开发者_如何学运维ss, but it doesn't work:
RewriteRule ^(en|de)?/images.png\?domain=(.*) /images/$2.png [QSA,L]
Any clue what's wrong?
just found the solution:
RewriteCond %{QUERY_STRING} ^domain=(.*)$
^ this line was missing to catch the Query String
RewriteRule ^(en|de)?/images.png$ /rating-images/%1.png [QSA]
At first glance, you probably need to escape the question mark that is part of the URL.
RewriteRule ^(en|de)?/images.png\?domain=(.*) /images/$2.png [QSA,L]
The query string is not part of what you're comparing to implicitly with RewriteRule, you need a RewriteCond to match/capture it to use in your substitution:
http://wiki.apache.org/httpd/RewriteQueryString
精彩评论