1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

.htacccess SEO friendly

Discussion in 'White Hat SEO' started by Bartman, Dec 9, 2010.

  1. Bartman

    Bartman Power Member

    Joined:
    Apr 24, 2010
    Messages:
    569
    Likes Received:
    131
    hi

    A long time ago, I modified my httaccess to redirect http://mysite.com to http://www.mysite.com
    also, I made another modification so that any page that is not found is redirected to homepage.

    are these 2 things search engine friendly?

    here are the codes in my htaccess, I really dont understand these, and i dont remember where i found them from:

    RewriteEngine on
    rewritecond %{http_host} ^mysite.com [nc]
    rewriterule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]

    RewriteCond %{THE_REQUEST} ^.*\/index\.html?
    RewriteRule ^(.*)index\.html?$ http://www.mysite.com/$1 [R=301,L]
     
  2. GreyWolf

    GreyWolf Executive VIP Jr. VIP

    Joined:
    Aug 17, 2009
    Messages:
    1,930
    Likes Received:
    5,389
    Gender:
    Male
    Occupation:
    Artist / Craftsman
    Location:
    sitting at my PC
    the first one is even recommended by google. You can set the canonical version (www or not) in webmaster tools, but it's still a good idea for the other SEs.

    The second redirect is a bad idea. It's better to make a custom 401 page. Two reasons, first the way your doing will mask errors from your web stats. The way it's working now you can't identify any problems where a link is broken on one of your pages. Second if the visitor is expecting to arrive on one page then arrives on your index page instead, all they know is they aren't where they wanted to be. If there isn't an immediate and obvious link to where they wanted to go then they'll just head back to where they came from.

    If you set up a custom 401 page then you can give it the same look as the rest of your site and include all the links the visitor needs to navigate your site, but they also get a message letting them know that the page they were looking for isn't there or has been moved or whatever. Make a good 401 page and the visitor is more likely to navigate through your site than either a default 401 or redirecting to your home page.

    Plus if you see a lot of people landing on your 401 page then you know there's a problem you need to work on.

    I don't usually bother making custom 401 pages myself, but I don't try to redirect them either. If your going to do anything about it though, a custom 401 is the better idea vs a redirect to the home page.
     
    • Thanks Thanks x 1
    Last edited: Dec 9, 2010
  3. Bartman

    Bartman Power Member

    Joined:
    Apr 24, 2010
    Messages:
    569
    Likes Received:
    131
    ok, thanks greywolf,
    so all i have to do is delete these lines
    RewriteCond %{THE_REQUEST} ^.*\/index\.html?
    RewriteRule ^(.*)index\.html?$ http://www.mysite.com/$1 [R=301,L]

    and then make a custom 404 page.

    right?
     
  4. GreyWolf

    GreyWolf Executive VIP Jr. VIP

    Joined:
    Aug 17, 2009
    Messages:
    1,930
    Likes Received:
    5,389
    Gender:
    Male
    Occupation:
    Artist / Craftsman
    Location:
    sitting at my PC
    Yeah that's what I would do if it were my site.

    In the purpose of that rewrite is for the case you described of using it to redirect page not found errors to your main page then I would rather see the stats for how much traffic is going to error pages. If you make sure there is a favicon.ico and robots.txt in your public dir then you really shouldn't see many errors in your stats. If you do then you know there's something that needs to be checked out.

    The main value of that type of redirect would be if you were redirecting an old domain with a lot of backlinks to many pages to your new domain and want them all to hit your the main page.

    If you really want to get fancy here is a tutorial on how to set up custom pages for each of the error codes you could get. It can be more friendly for your visitors and still give you stats to check up on the errors.
    Code:
    http://www.javascriptkit.com/howto/htaccess2.shtml
     
    • Thanks Thanks x 1