Rewriting URL

Topics: Developer Forum, User Forum
Oct 21, 2009 at 3:00 PM


I am rewriting URLs using the following rule:

RewriteRule  ^/([^\.]*)$  /Page.aspx?urlTerm=$1

The problem is when using the URL the Default.aspx page is not loading. when typing the URL or clicking a link to the page loads correctly.

I removed the RewriteRule and everything works just fine.


Any idea how to solve this problem?



Oct 21, 2009 at 4:41 PM

Your rule rewrites   to   . 

Check the IIRF log - you'll see messages showing which pattern matched.

The regex ^/([^\.]*)$ captures ZERO or more characters.  If there are zero characters, it will match.  Probably not what you want.

I can recommend Gerry Shaw's regex visualizer for help in designing and testing regex.  Also I can recommend the testdrivevr.exe that is included with IIRF for testing your rules.



Oct 21, 2009 at 10:28 PM

Thank you for your reply,

"The regex ^/([^\.]*)$ captures ZERO or more characters" - is it possible not to capture the "ZERO" characters, or to capture the url '' and rewrite it to '' ?

meanwhile ,I will use the tool you recommended to try figure it out.


Thanks again,


Oct 21, 2009 at 11:48 PM

Yes, it is possible to capture one or more characters, using a + quantifier, instead of a * quantifier.

regarding "is it possible to capture the URL" - I think what you want is to match the empty URL.  In this case it is

RewriteRule ^/?$     /Default.aspx  [L]

Which says, for any URL that is either empty, or consists of a single slash, rewrite to /Default.aspx.  The ^ is beginning-of-line and the $ indicates end-of-line, while the /? means zero or one slash.

Read the IIRF docs, there are lots of examples on regular expressions and specifically how they can be used within IIRF.