• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 650
  • Last Modified:

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?
0
anm1001
Asked:
anm1001
  • 2
1 Solution
 
hongjunCommented:
0
 
anm1001Author Commented:
When I tried this, it seems to go into an endless loop without displaying the page.  Is there another way?
0
 
hongjunCommented:
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

0
 
Rajar AhmedConsultantCommented:
in codebehind its may be never ending loop . Where as using javascript u may achieve . For eg.
In javascript . Get url using document.url and check it consists of index.aspx if it has navigate with some special query string and then check in code behind if that special  query string is not null then do that with 301 redirect . Sorry , Am not having visual studio ide right now using mobile version.  Hope you get into a right direction with this .
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now