stripping default.aspx from url issue

Topics: Developer Forum, User Forum
Sep 27, 2008 at 11:44 AM
Hi there,

I just started using IIRF and I have to say it's a great tool!

Just having one problem, it's more related but I hope someone can give me some pointers here:

I want to strip the default.aspx from the url with this:

RewriteRule  (.*)/default.aspx$ $1/ [I,RP]

That works fine, but then I get a 'page cannot be found" error. Which is logical because I just stripped it.
How do I map "/" to default.aspx in ASP.NET?
Oct 1, 2008 at 10:24 PM

I think you have it backwards.

What you want, I think, is for someone to type in and then on the server side, you want to run the default.aspx page.
You can do this with default documents of course, BUT that would change the address bar in the web browser. (It is implemented with a REDIRECT).

So you want to use a url rewriter.
That means something like:

RewriteRule  ^$  default.aspx    [I]

This means rewrite the "empty" URL, to default.aspx.  The browser is none-the-wiser that it has been rewritten on the server side. 

I am not sure why you are including RP as a flag. Not sure what that is all about. That is an ISAPI_Rewrite flag for "Redirect Permanently". But what you describe doesn't seem like a redirect. If you wanted a redirect you could do it in IIS with default documents.

Maybe you should read a little more or think about precisely what you want, or maybe you could describe it differently for me so I can understand it better.

Oct 2, 2008 at 4:10 AM
Ah ofcourse, I had it backwards indeed.

I also found out that writing down exactly what I want really helped writing down good rules.

The [RP] flag I got from some tutorial site. If you don't know what it's about, then it'll probably do nothing :D

Thanks Cheeso
Oct 2, 2008 at 9:24 PM
Edited Oct 2, 2008 at 9:25 PM
Glad that worked for ya, elgerm.
Maybe you could circle back to that tutorial site and notify them that [RP] is not meaningful for IIRF. That might help some other people.
(Unless the tutorial is for ISAPI_Rewrite).

Another thing that would be cool is if you could write up in english just what you wanted to do, and then show the rules you used to do it.
Might be helpful to others who are just learning.

You know what I find useful, also?  Put into comments in the ini file (using # characters) the english description of what the rule is supposed to do.
IIRF is sort of a specialized little tool, and I  guess we're not going to be writing rules every day.  So when you go back to it in 9 months, you'l be able to look at the notes you wrote and understand what the rule is supposed to do.

Oct 3, 2008 at 5:47 AM
Edited Oct 3, 2008 at 6:08 AM
Ok, here are some rules that help make my site multilingual and strip default.aspx from the address bar:

RewriteLog C:\tempiirf\iirf.out
RewriteLogLevel 3

# if the url is: "" or ""
# strip the language from the url but not from the address bar and go to the default.aspx page.
# remember the origional url by putting it in the HTTP_X_REWRITE_URL header.
# the HTTP_X_REWRITE_URL i can then get in ASP.NET to see what language the user
# put in the address bar.
# this way, google can find an English url and a Thai one.
RewriteRule ^/(en|th)/$ /Default.aspx [U]

# If default.aspx is hidden in the address bar, we still need to know we have to go to
# default.aspx. My error was that I put a Redirect directive here, which will result in
# showing the ugly default.aspx in the address bar.
RewriteRule ^$ /Default.aspx

# for all other pages the language is removed from the url, but not the address bar. This way I don't have to change
# anything in my code. ASP.NET will get to work with the stripped url while i can get to know what language the
# request is in via the HTTP_X_REWRITE_URL again.
RewriteRule ^/(en|th)/(.+) /$2 [U]

As for the RP directive, it was the article on
I see now other people have commented on the RP rule for IIRF a long time ago but it has not changed yet.



Oct 3, 2008 at 6:18 AM

great!  that should be very helpful.