Please help me with htaccess file

Discussion in 'Site & Server Administration' started by _Dmitry_, Jan 15, 2010.

  1. #1
    Hi!

    Please, help me setup redirection from <http://>; to <http://www.>;

    On mydomain I install wordpress and htaccess file looked like:
    ====================================================
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    Code (markup):
    ================================================

    In the file begin, I insert this code:

    ================================================
    # Always use www in the domain
    # Replace 'mydomain.com' with your domain name
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^([a-z.] )?mydomain\.com$ [NC]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .? <http://www.%1mydomain.com%{REQUEST_URI}>; [R=301,L]
    Code (markup):
    ================================================

    And as result, htaccess file look like:

    ================================================
    # Always use www in the domain
    # Replace 'mydomain.com' with your domain name
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^([a-z.] )?mydomain\.com$ [NC]
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule .? <http://www.%1mydomain.com%{REQUEST_URI}>; [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    Code (markup):
    ================================================

    But it doesn't help. Browser write - "WRONG REDIRECTION"

    Please help me Undecided

    Thanks!

    --
    Dmitry
     
    _Dmitry_, Jan 15, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.tolranet\.co\.uk [NC]
    RewriteRule (.*) http://www.tolranet.co.uk/$1 [R=301,L]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    Code (markup):
    The above redirects anything not www.tolranet.co.uk to www.tolranet.co.uk, you need to change the domain name, if you'd given your domain I'd have done it for you.
     
    tolra, Jan 15, 2010 IP
  3. graphicdesignmanchester

    graphicdesignmanchester Peon

    Messages:
    77
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\.tolranet\.co\.uk [NC]
    RewriteRule (.*) http://www.tolranet.co.uk/$1 [R=301,L]

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
     
    graphicdesignmanchester, Jan 16, 2010 IP