Modifying Wordpress .htaccess and force nonwww

Discussion in 'WordPress' started by Bohol, Feb 7, 2008.

  1. #1
    Hello,

    I want my blog to appear as www.mysite.com and that if I type a mysite.com the url would become a www.mysite.com I'm using Wordpress and I've been trying to configure the .htaccess at Wordpress folder but I failed.

    Anyone can suggest a solution of forcing nonwww to www url? Thanks.
     
    Bohol, Feb 7, 2008 IP
  2. DomainCo.US

    DomainCo.US Well-Known Member

    Messages:
    2,124
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    100
    #2
    add this to your .htaccess
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.your_domain.com$
    RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
     
    DomainCo.US, Feb 7, 2008 IP
  3. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi Domainco.Us, here's the .htaccess of Wordpress

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

    # END WordPress

    Where should I insert your suggestion? Top most part? Thank you.

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www.your_domain.com$
    RewriteRule ^(.*)$ http://www.your_domain.com/$1 [R=301]
     
    Bohol, Feb 7, 2008 IP
  4. mann3r

    mann3r Peon

    Messages:
    1,416
    Likes Received:
    100
    Best Answers:
    0
    Trophy Points:
    0
    #4
    before
    # BEGIN WordPress
     
    mann3r, Feb 7, 2008 IP
  5. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you, Mann3R. I appreciate your input.
     
    Bohol, Feb 7, 2008 IP
  6. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I inserted the above suggested rewrite code but I got this error instead:

    Moved Permanently
    The document has moved here.

    Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.
     
    Bohol, Feb 7, 2008 IP
  7. mann3r

    mann3r Peon

    Messages:
    1,416
    Likes Received:
    100
    Best Answers:
    0
    Trophy Points:
    0
    #7
    pm me, i might help.,
    I have just check the code above, seems you need to change form non www to www, try this
     
    mann3r, Feb 7, 2008 IP
  8. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Still, it doesn't work.
     
    Bohol, Feb 7, 2008 IP
  9. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I can't find a solution in Wordpress Forum.
     
    Bohol, Feb 7, 2008 IP
  10. mann3r

    mann3r Peon

    Messages:
    1,416
    Likes Received:
    100
    Best Answers:
    0
    Trophy Points:
    0
    #10
    try it, otherwise please pm me your blog info
     
    mann3r, Feb 8, 2008 IP
  11. gtull1

    gtull1 Guest

    Messages:
    619
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #11
    I had the same problem last night. I was using my host's cpanel to try to edit the .htaccess. I have been told that this is why mine may have not worked, but 2 scared 2 try again. lol
     
    gtull1, Feb 8, 2008 IP
  12. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #12
    You do know there's a plugin that lets you choose whether to redirect to either the .www or non-www version of your URL path, right? (This plugin also strips index.php from the URI strings as well.)

    It's called Enforce .www Preference.
     
    Dan Schulz, Feb 8, 2008 IP
  13. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #13
    I will give a try for the nth time. Thank you, Mann3r
     
    Bohol, Feb 8, 2008 IP