Link to home
Start Free TrialLog in
Avatar of anm1001
anm1001Flag for Afghanistan

asked on

301 redirect

I would like to setup a 301 redirect so that my home page index.aspx always defaults to the domain URL.  So for example, I would like for www.mysite.com/index.aspx to redirect automatically to www.mysite.com.

Can someone please help me with this?
Avatar of hongjun
hongjun
Flag of Singapore image

Avatar of anm1001

ASKER

When I tried this, it seems to go into an endless loop without displaying the page.  Is there another way?
In your index.aspx, try this.

<%@ Page Language="C#" %>
<script runat="server">
private void Page_Load(object sender, System.EventArgs e)
{
	Response.Status = "301 Moved Permanently";
	Response.AddHeader("Location","/");
}
</script>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rajar Ahmed
Rajar Ahmed
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial