Please verify :)

Discussion in 'Apache' started by boron, Feb 28, 2007.

  1. #1
    Hi, I've found many variants of code to make 301 redirect from www to no-www domain or vice versa, can anyone confirm if below codes are universal enough to use them in any case?

    1. From No-www to www redirect:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    Rewritecond %{http_host} ^domain.com [nc]
    Rewriterule ^(.*)$ http://www.domain.com/$1 [r=301,nc] 
    </IfModule>
    Code (markup):

    2. From www to No-www redirect:

    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    Rewritecond %{http_host} ^www.domain.com [nc]
    Rewriterule ^(.*)$ http://domain.com/$1 [r=301,nc]
    </IfModule>
    Code (markup):
    Are all above lines necessary? Can I omit something?

    3. I saw below code in some cases. Should it be added to above lines?
    Options +FollowSymlinks
    Code (markup):
    What this "operator" does?
    "^"
    Code (markup):
    4. Is this way of creating .htaccess file appropriate?
    Create .htaccess file: Go to Notepad, copy-paste above code in and save it as htaccess.txt. Upload it in a root directory on your site and rename it in .htaccess .

    5. Immediately after that check server header with this tool: http://www.webweaver.nu/tools/server-headers/ . It should tell you that 301 permanent redirect has been done. Is this OK?
     
    boron, Feb 28, 2007 IP
  2. boron

    boron Well-Known Member

    Messages:
    1,072
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    140
    #2
    Great! So, you all agree above codes are OK?

    Just to be sure, can some programmer please copy and paste below in the thread:
    1. I agree
    2. Do not agree (tell what's wrong then).
     
    boron, Mar 1, 2007 IP
  3. clixxer

    clixxer Peon

    Messages:
    47
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think it should work.
     
    clixxer, Mar 1, 2007 IP
  4. boron

    boron Well-Known Member

    Messages:
    1,072
    Likes Received:
    40
    Best Answers:
    0
    Trophy Points:
    140
    #4
    OK, anyone else can confirm with certainty that 1. and 2. codes are correct?
     
    boron, Mar 8, 2007 IP
  5. jhnrang

    jhnrang Notable Member

    Messages:
    4,107
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    225
    #5
    I also need the info--I am worried that my PR will be divided between the two URLs. :(

    Someone-- technically adept-- please let us know.
     
    jhnrang, Mar 12, 2007 IP