General rewrite rule question v2

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 1
Joined: 26 Apr 2012, 13:46

General rewrite rule question v2

26 Apr 2012, 13:51

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

User avatar
Posts: 871
Joined: 12 Mar 2012, 09:54

Re: General rewrite rule question v2

27 Apr 2012, 06:16

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]

User avatar
Posts: 16
Joined: 19 Nov 2012, 22:21

Re: General rewrite rule question v2

19 Nov 2012, 22:46

Hope this works, but I think it is only applicable for version 2, right?

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 13 guests