'pass through' for query strings

Jun 27, 2009 at 2:29 PM

Hi

Firstly thank you for the excellent Rewrite Filter.

We currently have this entry for static data:

RewriteRule /(.*).(?:css|jpeg|jpg|gif|png|js|ico|xml|html|txt|htm|aspx)$ /$0 [I,L]

The only problem is that querystrings do not get to the aspx pages.

e.g. when the url is domain.com/home.aspx?search=mysearch

The server will only see domain.com/home.aspx and not the querystring.

How should i modify this to handle both URLs with and without querystrings.

Thanks

B

 

Coordinator
Jun 28, 2009 at 10:47 AM
Edited Jun 28, 2009 at 10:50 AM

Can you tell me more about what you are doing?

You said that you use that entry for "static data".   But the rule has .aspx as an extension, which I Think is not "static data".   Can you clear this up?

I don't see anything in the rule that matches a query string.  Are you intending to match a query string - something with a ? followed by some text?

There's a testdriver tool - have you tried it out? When I tried it, I got this result:

--------------------------------------------
Sun Jun 28 06:35:53 -  3744 - ReadConfig: setting LogLevel to 4
Sun Jun 28 06:35:53 -  3744 - LogFile re-opened.
Sun Jun 28 06:35:53 -  3744 - ReadConfig: new log file name: 'c:\temp\iirf.8752.log'
Sun Jun 28 06:35:53 -  3744 - ReadConfig: line 14: IterationLimit 5
Sun Jun 28 06:35:53 -  3744 - ReadConfig: line  17: RewriteRule (rule 1)  '/(.*).(?:css|jpeg|jpg|gif|png|js|ico|xml|html|txt|htm|aspx)$'  '/$0'    [I,L]
Sun Jun 28 06:35:53 -  3744 - ParseRuleModifierFlags: '[I,L]'
Sun Jun 28 06:35:53 -  3744 - ReadConfig: Done reading, found 1 rules (0 errors, 0 warnings) on 20 lines

--------------------------------------------
Sun Jun 28 06:35:53 -  3744 - Initialize: Ionic ISAPI Rewriting Filter (IIRF) v1.2.15 final R5
Sun Jun 28 06:35:53 -  3744 - Initialize: config file 'bernie\IsapiRewrite4.ini'
Processing URLs...(bernie\SampleUrls.txt)

Sun Jun 28 06:35:53 -  3744 - EvaluateRules: depth=0
Sun Jun 28 06:35:53 -  3744 - EvaluateRules: Rule 1 : -1 (No match)
Sun Jun 28 06:35:53 -  3744 - EvaluateRules: returning 0

NO ACTION 'home.aspx?search=mysearch' ==> --

Sun Jun 28 06:35:53 -  3744 - DllMain PROCESS_DETACH

Using your single rule, and a sample URL of "home.aspx.?search=mysearch", there is "No match" as you can see. No match and NO ACTION, in other words, no rewrite of that request. And even before running the tool, I would have bet on that since there's nothing in the pattern that would match the ?

That testdriver tool is really useful. You can use it to try different patterns, rulesets, and URLs. You know another really useful thing? the readme. It has really good hints and will help you do what you want.

I don't know exactly what you want - I'm sure it is not only "rewrite static URLs to the same URLs" because that is a no-op. You don't need to rewrite a URL request for a css file to the same URL. I'm sure you know that. I'm sure you know what you want, much more clearly than I do. Check the readme and it will help you.

You *might* want multiple rules - one for static content with no query string, and another for aspx with  no query string, a third for aspx with a query string. If so, this might look like this:

  # static content 
  RewriteCond %{QUERY_STRING} ^$
  RewriteRule /(.+)\.(css|jpeg|jpg|gif|png|js|ico|xml|html|txt|htm)$ /static/$0 [I,L]

  #  aspx with empty query string 
  RewriteCond %{QUERY_STRING} ^$
  RewriteRule ^/(.+)\.aspx$   /pages/$1.aspx [L]

  #  aspx with non-empty query string
  RewriteCond %{QUERY_STRING} ^.+$
  RewriteRule ^/(.+)\.aspx\?(.+)$   /pages/$1.aspx?$2 [L]

This is just an idea. Try out the testdriver tool to see what makes sense for you.