www and not www

Discussion in 'ASP.NET / ASP.NET Core' started by Takeshi Eto, Nov 16, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

  2. Hi all,
    Regarding site http://www.bkkbooks.com and http://bkkbooks.com

    Google gives a pr of 1 for the without www but zero with the www.
    Infact the site is indexed more without the www. We want people and search engines to go to the www pages. We don't want the no www to be indexed by the seach engines. Or are we wrong and is it ok?

    How do we solve this problem

    We have a number of old pages that we deleted. Basically we changed the names of the pages. The old names are still indexed in search engines and of course if someone clicks them they get an error. How do we set up a 301 redirect for these old names. Or is there another method.

    I hope I have posted this in the correct part of the forum

    Look forward to your answers
    Many thanks
     
  3. Hi thanks for the quick reply.
    Regards 'The first thing to do is to resubmit your site to google'

    Yes we have done that. Plus made a site google map.

    Still the issue with www and no www being rated higher. Do you have any other ideas please. Would rather just have the www rated. By the way will this weaken the strength as in pr of the site???

    It is strange as we don't have this issue with other web sites.

    All the Best
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    oh well.. i am not sure!!

    Google guards it ranking algorithm and very few understand how it work.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Hi Bruce,
    Thanks for the reply.
    I guess because the site is in dmoz without the www this may be the reason why.
    I will use the custom error with manage IIS in the control panel to solve the bad links ie 404 error.

    All the Best
     
  6. You may want to set up a 301 redirect to avoid duplicate content issues.


    I found that the best way to do it is to add following lines to your global.asax BeginRequest event:


    'Check for www
    If Request.Url.ToString.IndexOf("www.") < 0 Then


    Dim mypage As String = Request.Url.ToString.Insert(Request.Url.ToString.IndexOf("//") + 2, "www.")


    'Check if URL is like http://mysite.com/default.aspx (You want to have consistent linking / redirecting. Therefore we cut off
    the "/default.aspx" bit)


    If myPage.ToLower.EndsWith("/default.aspx") Then
    myPage = myPage.Substring(0, myPage.IndexOf("/default.aspx"))
    End If


    Response.Redirect(myPage)
    Response.StatusCode = 301


    'The restof the global.asax should be ignored as events will be fired again after the redirect....
    Exit Sub
    End If
    Using the 301 redirect should also transfer the pagerank from your non-www pages to the www pages.

    I hope that helps,

    Markus

    estates24
    www.estates24.com
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    Hmm...

    global.asax and global.asa is a file the gets executed first when a ASPx or ASP page is called.

    However, I checked your site and see that most of your pages are written in HTML. This approach may not work for you unless you change your site to ASPX or ASP technology which is a daunting task!

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  8. Dear Markus and all
    Thanks for your information.
    Problem is that I don't understand the meaning of add following lines to your global.asax BeginRequest event:
    Where is my global.asax?

    Many thanks Markus. I checked out your site and yep tha is what I want to happen.

    Hope you can explain a bit more for a dummy like me.
     
  9. Thanks for the reply Bruce,
    Well I have no choice but to change all sites looked after by me to aspx pages or move over to an apache server where one can do a few lines in a htaccess file and the problem is solved. I am now on day 3 of 8 hours per day reading up on this matter . In fact people can use this issue as a weapon by linking to your site without the www then later google penalizes you. One loses pr in google because it thinks you have two sites with the same content. Stupid google eh.

    I have no problem changing all sites to aspx files. However the redirecting of all files plus the non www redirect to the www is my problem.
    Is there a complete script somewhere for the global.asax somewhere in that I just have to change to the page and or domain I want. I can manage that if you know where I can copy and paste one. Do the clearly marked changes save to my test site plus to the ones I help with and of course rename the files to . aspx and copy and paste any necessary code in these files again changing any clearly marked areas.
    Hope you can help or point me in the right direction as this issue needs to be solved.
     
  10. Bruce

    Bruce DiscountASP.NET Staff

    I doubt that there's a script out there that would be canned enough for you to just copy it into your site. Markus' post is as good as it can be. Global.asax is designed for general purpose usage and not specfically URL rewriting.

    To be honest, if your website only uses static HTML, it may be better off moving to an Apache server. You can easily do this type of stuff w/ .htaccess however it is fairly difficult w/ IIS.

    I sure hope Microsoft will come out with something that can handle some type of URL rewriting w/o programming!!

    Sorry can't be of much help.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page