301 Redirect Question!

8 replies
  • SEO
  • |
Hi Warriors,

Let's say that I have a website and you can access the content as below...This will create duplication issues in Google if I understood it correctly.

www.abc.com
www.abc.com/index.html
www.abc.com/index.asp
www.abc.com/
abc.com
www.abc.com/home.html

From my understanding, to solve the issue I would have to create a 301 redirect to tell Google my preferred URL version.
So would this be the correct code to take care of all the canonical issues above so Google will recognize that www.abc.com is the referred version by putting this in the .htaccess file? Or is there anything else that is needed? Also would this be applicable to all sites (asp,php,html, jsp etc)?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^abc\.com
RewriteRule (.*) http://www.abc.com/$1 [R=301,L]


Appreciate Your Help..

Many Thanks,

Chloe
#301 #question #redirect
  • Profile picture of the author TomBond
    I think this problem is less important than it once was. Google know's that so many sites have www.mydomain.com and www.mydomain.com/index that it's aware they are not all scammers.

    I can't help you with code though I'm afraid but I wouldn't say if in doubt just do each iteration seperatly.
    {{ DiscussionBoard.errors[1325091].message }}
  • Profile picture of the author Geraldm
    Hi,

    Adding redirect rules to the .htaccess file is best.

    The following code will redirect users (as well as Google) to the www version of the website as well as redirect index webpages to the standard root /

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.abc\.com$ [NC]
    RewriteRule ^(.*)$ http://www.abc.com/$1 [L,R=301]
    redirect 301 /index.html http://www.abc.com/
    redirect 301 /index.asp http://www.abc.com/
    redirect 301 /home.html http://www.abc.com/

    Hope this helps.



    {{ DiscussionBoard.errors[1325132].message }}
    • Profile picture of the author Chloe Brooks
      Thanks a lot Netfq,
      So basically the below script will work on all websites (php,asp,html, jsp etc)?

      So if I want to make sure that people who type in abc.com without the www and I want this 301 redirect to www.abc.com, should I just add that to the below and if so how?


      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\.abc\.com$ [NC]
      RewriteRule ^(.*)$ http://www.abc.com/$1 [L,R=301]
      redirect 301 /index.html http://www.abc.com/
      redirect 301 /index.asp http://www.abc.com/
      redirect 301 /home.html http://www.abc.com/

      Thanks a million
      Chloe
      {{ DiscussionBoard.errors[1328404].message }}
      • Profile picture of the author Geraldm
        Originally Posted by Chloe Brooks View Post

        So basically the below script will work on all websites (php,asp,html, jsp etc)?
        No.. It will only work on apache servers which have modrewrite installed.

        Originally Posted by Chloe Brooks View Post

        So if I want to make sure that people who type in abc.com without the www and I want this 301 redirect to www.abc.com, should I just add that to the below and if so how?
        Just add the following lines to the bottom of your .htaccess file:

        RewriteEngine On
        RewriteCond %{HTTP_HOST} !^www\.abc\.com$ [NC]
        RewriteRule ^(.*)$ http://www.abc.com/$1 [L,R=301]
        {{ DiscussionBoard.errors[1328627].message }}

Trending Topics