Any danger in this?

Discussion in 'HTML & Website Design' started by swollenpickles, Nov 14, 2006.

  1. bobby9101

    bobby9101 Peon

    Messages:
    3,292
    Likes Received:
    134
    Best Answers:
    0
    Trophy Points:
    0
    #21
    actually my code is slightly different, plus it alerts him that he needs to chyange his domain.
     
    bobby9101, Nov 16, 2006 IP
  2. swollenpickles

    swollenpickles Active Member

    Messages:
    1,271
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    80
    #22
    So if I used this code what do I change and do I just paste it into the .htacess file?

    RewriteCond %{HTTP_HOST} !^fully\.qualified\.domain\.name [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://fully.qualified.domain.name/$1 [L,R]
    Code (markup):
     
    swollenpickles, Nov 16, 2006 IP
  3. SoKickIt

    SoKickIt Active Member

    Messages:
    305
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    70
    #23
    I have and I posted it. This is what you get when you run the script:

    [​IMG]
     
    SoKickIt, Nov 17, 2006 IP
  4. Sem-Advance

    Sem-Advance Notable Member

    Messages:
    6,179
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    230
    #24
    Fair enough....I thought about this and it seems it would do the samething.

    I have to assume the mod url is less taxing on the server than the 301 but not sure.....why would there be two seperate instuctions from Apache and W3C??

    One thing you have to remember is Google is using the code through their server... and that might not be the best thing for your site / server.
     
    Sem-Advance, Nov 17, 2006 IP
  5. TechEvangelist

    TechEvangelist Guest

    Messages:
    919
    Likes Received:
    140
    Best Answers:
    0
    Trophy Points:
    133
    #25
    1. You MUST use a 301 redirect for this to work properly, particularly if the search engines have indexed two versions of the site's URLs. A 301 tells the spider that the change is permanent, which causes the search engine to replace the old URL in their database with the new. It is used to assure that spiders do not double index a site under two different versions of a URL, which can sometimes lead to duplicate content issues. The search engines are supposed to figure this out through a process called Canonicalization, but they don't always get it right. Here is the definitive word from Matt Cutts: http://www.mattcutts.com/blog/seo-advice-url-canonicalization/

    2. swollenpickles, do not use that code literally. It will not work until you plug your domain name into it.

    3. This is the correct version. You need to escape the dot in the RewriteCond statement with a backslash and force a 301 in the RewriteRule statement. You can force a 301 by using either R=301 or R=permanent. You may or may not need the first line, depending upon your server configuration. I always place it in the .htaccess file as the first lines of code in every site I set up.
    Options +FollowSymLinks 
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain\.com
    RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]
    Code (markup):
    4. You must verify that a 301 status code is being generated. Use one of the online header checkers, such as http://web-sniffer.net/.

    5. The .htaccess file only works on Linux and Unix servers running Apache.

    6. The .htaccess file is a hidden file, which means you may not see it with your FTP utility. If you cannot see the file, read this article for tips regarding how to make the file visible to your FTP tool. Why can't I see my .htaccess file with WS_FTP or CuteFTP?

    7. You MUST use a plain text editor, such as Notepad, when working with this file. Using Word or editors that attach headers or formatting code may screw it up.

    8. Placing this code in the .htaccess file does not make it server intensive. The .htaccess file is a type of filter. With mod_rewrite, no action is taken unless the conditions are met. Yeah, you can overload the .htaccess file, but if this is all that you are doing, it will not bog down your server.
     
    TechEvangelist, Nov 17, 2006 IP
    swollenpickles likes this.
  6. swollenpickles

    swollenpickles Active Member

    Messages:
    1,271
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    80
    #26
    Thanks for your post, very thorough. I think i have it sorted out now.
     
    swollenpickles, Nov 17, 2006 IP