site.com/folder/ to www.site.com/folder/

Discussion in 'Apache' started by Solicitors Mortgages, May 15, 2007.

  1. #1
    I can get site.com to change to www.site.com using .htaccess

    I can't seem to get it to work with any folders :confused:

    here's what I have....
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^site\.com$ [NC]
    RewriteRule ^(.*)$ http://www.site.com/$1 [R=301,L]

    but if you type in site.com/blog it still goes to the NON-www version of the blog

    :confused:
    help appreciated
    James.
     
    Solicitors Mortgages, May 15, 2007 IP
  2. adultuserbars

    adultuserbars Peon

    Messages:
    762
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this code:
    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{http_host} ^site\.com [nc]
    RewriteRule ^(.*)$ http://www.site.com/$1 [r=301,nc]
    Code (markup):
     
    adultuserbars, May 15, 2007 IP
  3. Solicitors Mortgages

    Solicitors Mortgages Well-Known Member

    Messages:
    2,217
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Solicitors Mortgages, May 15, 2007 IP
  4. Solicitors Mortgages

    Solicitors Mortgages Well-Known Member

    Messages:
    2,217
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    103
    #4
    update::

    I can do
    mysite.com to www.mysite.com

    I can do
    mysite.com/forum to www.mysite.com/forum

    But It will not let me do
    mysite.com/blog to www.mysite.com/blog

    not sure if the htaccess in the wordpress folder is causing the problem, but the blog doesn't work at all if I delete it. This is what I have in the root htaccess:

    Options +FollowSymlinks
    RewriteEngine on
    RewriteCond %{http_host} ^mysite\.com [nc]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [r=301,nc]
    Code (markup):
    the one in the blog folder is the standard one:

     
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /myblog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /myblog/index.php [L]
    </IfModule>
    # END WordPress
    
    Code (markup):
     
    Solicitors Mortgages, May 15, 2007 IP
  5. adultuserbars

    adultuserbars Peon

    Messages:
    762
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How is your WP blog setup? Is it supposed to be in the main page, or a directory below the main site?

    If the blog is in a directory such as http://mysite.com/blog just put the WP rewrite lines in a .htaccess file where your blog is located.

    Just put the code that I posted before, in the .htaccess file in the public_html/ folder and it will work for every single folder you have on your site. All of them will be redirected to have the www. at the start of every domain.

    If you would like, give me temp FTP details of your site so that You can show me where you are putting the code. And I can fix it for you.
     
    adultuserbars, May 15, 2007 IP
  6. Solicitors Mortgages

    Solicitors Mortgages Well-Known Member

    Messages:
    2,217
    Likes Received:
    139
    Best Answers:
    0
    Trophy Points:
    103
    #6
    It's in a directory one level below main.
    I have tried putting the wordpress .htaccess in the root and in the actual folder it came with. The same with the 301 htaccess.
    Odd that it would make the forum redirect but not the blog :confused:

    Very kind, I will take you up on that as soon as I get the site open. Thanks.

    James.
     
    Solicitors Mortgages, May 16, 2007 IP
  7. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #7
    What about the wordpress settings under options?
    Maybe you need to add www to
     
    cyanide, May 16, 2007 IP