Please help me with htaccess file

Discussion in 'General Scripting Chat' started by Foster, Jan 15, 2010.

  1. Foster

    Foster Newbie

    Joined:
    Jul 23, 2009
    Messages:
    42
    Likes Received:
    4
    Hi!

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

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

    In the file begin, I insert this code:

    ================================================
    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]
    ================================================

    And as result, htaccess file look like:

    ================================================
    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]
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress
    ================================================

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

    Please help me [​IMG]

    Thanks!

    --
    Dmitry
     
  2. migcosta

    migcosta Registered Member

    Joined:
    Jan 6, 2009
    Messages:
    55
    Likes Received:
    9
    Sorry but I don't quite understand what you want to do..
    Don't you have an administration panel to configure that on apache?
    But anyway:

    Code:
    RewriteCond %{HTTP_HOST} \.
    RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
    RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
    RewriteCond %{SERVER_PORT} !^80$
    RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L] 
    
    
    I think this will do ;)