homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

How to 301 redirect default.aspx to root

5+ Year Member

Msg#: 3405231 posted 1:40 pm on Jul 26, 2007 (gmt 0)

I'm currently trying to do a 301 redirect like this

http://www.example.com/default.aspx to

But if I change this in IIS it creates a loop, and if I change it in the aspx.vb file it creates a loop....I don't know what to do. I have look all over the net and can't get an answer!

Code aspx.vb file:
If InStr(LCase(Request.ServerVariables("URL")), "default.aspx") > 0 Then
Response.Status = "301 Moved Permanently"
Response.AddHeader("Location", "http://www.example.com")
End If

Please help!

[edited by: encyclo at 2:28 pm (utc) on July 26, 2007]
[edit reason] switched to example.com [/edit]



5+ Year Member

Msg#: 3405231 posted 6:25 pm on Jul 31, 2007 (gmt 0)

Your problem is that example.com is, in essence, running example.com/default.aspx, since this is your default page. This redirects to example.com again, which will redirect yet again... creating an infinite loop.

This should be done through IIS if at all possible, not through ASP.NET.

Edit: Forgot to mention, you'll probably need a rewriting engine for IIS to accomplish this--I don't believe it provides URL rewriting capabilities by default.

[edited by: WesleyC at 6:26 pm (utc) on July 31, 2007]


WebmasterWorld Senior Member 10+ Year Member

Msg#: 3405231 posted 8:30 pm on Jul 31, 2007 (gmt 0)

Somewhere in this forum is a post that described how to accomplish this and it had something to do with the fact that Microsoft used a capital D on Default. I wanna say the thread was roughly 6 Months ago.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved