301 redirects and domain pointers

Discussion in 'General troubleshooting' started by joey2506, Apr 24, 2012.

  1. Hi,

    I'm just in the middle of setting up a new website, I've set up the domain pointer and put a redirect in the web.config file on my root directory.

    http://pixelheads.org/pixel/
    http://pixelheads.com.au/

    Both websites show the same page, but what I'm now trying to do is set up a 301 redirect so whenever somebody goes to the first URL it redirects them to the second URL (I don't want google seeing it as duplicate content).

    I've put a global.ascx file in my root directory with the follwing code:

    Code:
    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
    If HttpContext.Current.Request.Url.ToString().ToLower().Contains("http://pixelheads.org/pixel/") Then
    	    HttpContext.Current.Response.Status = "301 Moved Permanently"
    	    HttpContext.Current.Response.AddHeader("Location", Request.Url.ToString().ToLower().Replace("http://pixelheads.org/pixel/", "http://pixelheads.com.au"))
        End If
    End Sub
    Code from: http://www.mycsharpcorner.com/Post.aspx?postID=40

    But, when I go to the first URL it doesn't take me to the second URL.

    What am I doing wrong?

    Thanks in advance.
     
  2. ComputerMan

    ComputerMan Winhost Staff

    Last edited by a moderator: Oct 14, 2015
  3. Would that work the same way as a 301 redirect?

    My main concern is with google seeing the two URL's with duplicate content.
     
  4. ok, so i found some documentation on setting 301 redirects from IIS7.

    i've followed all the steps outlined in the following post:
    http://forum.Winhost.com/showpost.php?p=16299&postcount=8

    and pixelheads.org/pixel/ now redirects to pixelheads.com.au, but pixelheads.com.au comes up with the following error:

    This webpage has a redirect loop
    The webpage at http://www.pixelheads.com.au/ has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

    help?
     
    Last edited by a moderator: Oct 14, 2015
  5. ComputerMan

    ComputerMan Winhost Staff

    Try to disable to redirect rule you did in your global.ascx file to see if that helps.
     
  6. i removed the global.ascx file and it's now pointing to the root directory of my hosting, which just has the "Site is Under Construction" splash page.

    it looks like it's ignoring my domain pointer? or do i need to do something different?
     
  7. ComputerMan

    ComputerMan Winhost Staff

    Thinking out side the box for a moment.

    Why do you have your web application on the sub-directory? http://pixelheads.org/pixel/

    The main application is hosted here: http://pixelheads.org/pixel/

    But your domain pointer: http://pixelheads.com.au/ is pointing to http://pixelheads.org/pixel/ (The main domain hosting the web app.)

    In your first statement you stated that both links were working correctly because you manage to have your domain pointer point to http://pixelheads.org/pixel/

    Why not simply install the web application on to the root of your site and not in a subdirectory? That way you can simply redirect the URL to the URL of your choice.

    You stated that you want the first URL:
    http://pixelheads.org/pixel/ to redirect to http://pixelheads.com.au/

    My Suggestion to you is to change the domain name on the hosting account to pixelheads.com.au and install the web application on the root of your site. Then you can simply redirect pixelheads.org to pixelheads.com.au using this script here: http://www.seoworkers.com/seo-articles-tutorials/permanent-redirects.html#vbscript

    Just Another Suggestion :)
     

Share This Page