Welcome to WebmasterWorld Guest from

Forum Moderators: ocean10000

Message Too Old, No Replies

How to 301 redirect default.aspx to root



1:40 pm on Jul 26, 2007 (gmt 0)

5+ Year Member

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]


6:25 pm on Jul 31, 2007 (gmt 0)

5+ Year Member

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]


8:30 pm on Jul 31, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

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.

Featured Threads

Hot Threads This Week

Hot Threads This Month