.htaccess code to manage 301 redirect for static website

Discussion in 'Site & Server Administration' started by solushunz1, Jun 5, 2011.

  1. #1
    I have a website which has canonical issues.
    I have already done the testing for it. when I open http://mywebsite.com it opens without redirecting it to http://www.mywebsite.com.

    Can someone give me exact code which I can add to my .htacess file to fix this issue.

    I want searchengines to recognize just the www.mywebsite.com version not the non-www version.
    :)
     
    solushunz1, Jun 5, 2011 IP
  2. stardust.x7

    stardust.x7 Active Member

    Messages:
    369
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    90
    #2
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^domain.com
    RewriteRule (.*) http://domain.com/$1 [R=301,L]

    ---- This should work, try this :)
     
    stardust.x7, Jun 6, 2011 IP