Redirects for .aspx Files - Can Anyone Help?

7 replies
  • SEO
  • |
Hi guys,

I am wanting to perform the redirect of www.domain.com/default.aspx to www.domain.com to sort canonicalisation issues - apparently this cannot be done because it will be set to an infinite loop as they are essentially the same file - I'm not a techy, but does this make sense?!!

Is the only option to use a robots.txt file in this case?

Best regards,

Mischa
#aspx #files #redirects
  • Profile picture of the author Yoyas
    You can the redirection in htaccess, something like:

    Code:
    Redirect 3w.domain.com 3w.domain.com/default.aspx
    I can post url, so change 3w to build the link. I think that works pretty well
    {{ DiscussionBoard.errors[471787].message }}
    • Profile picture of the author Misch.Chief
      Thanks for the reply,

      Can you definitely use htaccess redirects with aspx files ,which I believe run at server side (I don't really know whqat I'm talking about I'm afraid!!)?

      Mischa
      {{ DiscussionBoard.errors[471812].message }}
      • Profile picture of the author Misch.Chief
        Hi,

        I had heard you can do it using JavaScript. I was wondering if the search engines have the ability to read that script and whether anyone else has used this method?

        Method:

        <script runat="server">
        private void Page_Load(object sender, System.EventArgs e)
        {
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location","http://www.new-url.com");
        }
        </script>

        Thank you,

        Mischa
        {{ DiscussionBoard.errors[471814].message }}
        • Profile picture of the author dburk
          Hi Mischa,

          You should never include the default.aspx file name in a URL because its redundant. As you have discovered, it also leads to canonicalisation issues.

          You can fix this issue by changing the order of your default pages. IIS allows you to set the preferred order of your default pages based on file name.

          1. Set you default.asp file to be served before your default.aspx file.

          2. Create a default.asp file with the following code and place in your root directory:

          Code:
          <%If Right(LCase(Request.ServerVariables("URL")),11)="default.asp"Then Server.Transfer "default.aspx" End If%>
          3. Add the following line of code at the top of your default.aspx file:

          Code:
          <%If Right(LCase(Request.ServerVariables("URL")),12)="default.aspx"Then Reponse.Redirect "/" End If%>
          {{ DiscussionBoard.errors[472033].message }}
    • Profile picture of the author KirkMcD
      Originally Posted by Yoyas View Post

      You can the redirection in htaccess,
      It's a Windows server, htaccess, won't work.

      Here is an ASP.Net solution:
      ASP.NET 301 redirect
      {{ DiscussionBoard.errors[471994].message }}
  • Profile picture of the author Misch.Chief
    Many thanks for your help with this everyone - greatly appreciated!
    {{ DiscussionBoard.errors[483163].message }}

Trending Topics