General rewrite rule question v2
3 posts
• Page 1 of 1
- [email protected]
- Posts: 1
- Joined: 26 Apr 2012, 13:46
General rewrite rule question v2
I have a working rewrite rule that I just want some opinion on. Currently using rewrite v2. NOT upgrading to v3.
I use the following:
RewriteRule ^(.*)\.spp[a-fA-F0-9]+\.(css|js|png|gif|jpg|jpeg|ico|woff|ttf|eot|svg|swf) $1.$2 [I]
Which will rewrite URLs such as: foo.a0b1.jpg -> foo.jpg
It works well, but I wanted opinion if:
1) I'm using the best syntax.
2) I'd like to make the rule a bit more versatile as to support ANY file extension so as I support more file type, I don't have to modify my rule each time.
3) What's the best way to query string append (QSA) in v2. v2 does not seem to support the QSA directive.
Thanks in advance.
Marc
I use the following:
RewriteRule ^(.*)\.spp[a-fA-F0-9]+\.(css|js|png|gif|jpg|jpeg|ico|woff|ttf|eot|svg|swf) $1.$2 [I]
Which will rewrite URLs such as: foo.a0b1.jpg -> foo.jpg
It works well, but I wanted opinion if:
1) I'm using the best syntax.
2) I'd like to make the rule a bit more versatile as to support ANY file extension so as I support more file type, I don't have to modify my rule each time.
3) What's the best way to query string append (QSA) in v2. v2 does not seem to support the QSA directive.
Thanks in advance.
Marc
Re: General rewrite rule question v2
Hello, Marc
Here's how I see the best way to write your rule accounting for all your requirements:
RewriteRule /(.*)\.spp[a-fA-F0-9]+\.(\w+)(?:\?(.+))? /$1.$2(?3\?$3) [I,L]
Here's how I see the best way to write your rule accounting for all your requirements:
RewriteRule /(.*)\.spp[a-fA-F0-9]+\.(\w+)(?:\?(.+))? /$1.$2(?3\?$3) [I,L]
Re: General rewrite rule question v2
Hope this works, but I think it is only applicable for version 2, right?
3 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests