Posted By curlyfro on 15/10/2005 8:05:05 PM
an personal page is in this format http://www.otbradio.com/SubliminalThought/tabid/247/Default.aspx.
i'd like to give each user a url in the form of
http://www.otbradio.com/SubliminalThought/ which gets mapped to the above.
is this possible with rewrite rules?
It is possible, but requires some IIS changes. By default a request to a non-existant physical file like SubmliminalThought would get handled by default 404 handler from IIS and never enter the ASPNET process to be rewritten.
The first step is to make all requests go through the ASPNET process. This will incur a little extra processing on the web server's behalf as it will send images etc through the aspnet process. To map all requests to the aspnet process see this article here:-
http://www.dotnetdevs.com/articles/AttributeBasedURLDispatch.aspx
(the section is under "does it work for all urls" and will show you how to do this for Windows 2003)
Now that all requests go through the aspnet process we can rewrite that request if its in our rules.
Here were the rules I added for www.ventrian.com:-
<RewriterRule>
<LookFor>/</LookFor>
<SendTo>~/default.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/Login</LookFor>
<SendTo>~/default.aspx?ctl=login</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>/Friendly</LookFor>
<SendTo>~/default.aspx?TabId=79</SendTo>
</RewriterRule>
You'll notice there is a default one there (/), this is because it never gets to the default.aspx file, this is only redirected when a file is not found (when not piping everything through the aspnet process)
So, the following URLs shoudl now work:-
http://www.ventrian.com/login
http://www.ventrian.com/friendly
One day soon, I'm going to build some screens so you could do this on a per portal basis and make things a bit easier.
|