rewriterule with multiple optional arguments

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 2
Joined: 14 Sep 2012, 15:37

rewriterule with multiple optional arguments

19 Sep 2013, 17:34

hello all,

I have to rewrite multiple variables separated by / to the same but separated by &, the problem is that the number of variables is not always the same, it is optional.

It can go from 3 variables to 12, now I have 9 rewrite rules, starting by 12 variables and finishing with 3 but looks like this number keeps changing.

These are some lines of what I have now:

RewriteRule ^ABC/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)(.*) /Site.aspx?&$1&$2&$3&$4&$5&$6&$7 [NC,I]
RewriteRule ^ABC/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)(.*) /Site.aspx?&$1&$2&$3&$4&$5&$6 [NC,I]
RewriteRule ^ABC/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)(.*) /Site.aspx?&$1&$2&$3&$4&$5 [NC,I]
RewriteRule ^ABC/([^/]*)/([^/]*)/([^/]*)/([^/]*)/([^/]*)(.*) /Site.aspx?&$1&$2&$3&$4 [NC,I]
RewriteRule ^ABC/([^/]*)/([^/]*)/([^/]*)/([^/]*)(.*) /Site.aspx?&$1&$2&$3 [NC,I]

Is it possible to have all this in only one line and not depending anymore on the number of parameters?


Thank you,
Charly

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: rewriterule with multiple optional arguments

20 Sep 2013, 00:23

Hello,

I can tell from the experience, that having from 3 to 12 simple rules is better and more reliable than 1 complicated. There's no magic fixes, and if there's it's will not ensure flawless performance.
My suggestion would be to leave those rules as is, since they are doing the job.

Regards
Andrew

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: rewriterule with multiple optional arguments

20 Sep 2013, 00:24

You won't win performance by reducing the number of lines in this case.

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 14 guests