Results 1 to 6 of 6

www to non-www: Do I need a second htaccess RewriteCond for my Wordpress blog?

This is a discussion on www to non-www: Do I need a second htaccess RewriteCond for my Wordpress blog? within the General Discussion forums, part of the vBSEO SEO Plugin category; Note: I figured it would be best to ask this question in a new thread so it will be easier ...

  1. #1
    MTD
    MTD is offline
    Senior Member
    Real Name
    Mike
    Join Date
    Apr 2008
    Posts
    141
    Liked
    0 times

    Question www to non-www: Do I need a second htaccess RewriteCond for my Wordpress blog?

    Note: I figured it would be best to ask this question in a new thread so it will be easier for others with the same question to find.

    Currently, my forum uses the non-www URL version but my Wordpress uses the www for URLs. I will be changing my site to use the non-www version for URL.

    My vBulletin is located at example.com
    My Wordpress is located at example.com/blog/

    Thanks to Brian I know what I need to do for the vBulletin part and will be using this in the htaccess:
    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
    However there is another htaccess file found at domain.com/blog/. I don't recall ever modifying it when I set it up, but here's what it currently says:

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

    # END WordPress
    Do I need to modify this Wordpress htaccess file too so there are 301 redirects for the blog?

  2. #2
    Senior Member
    Real Name
    Michael Biddle
    Join Date
    Jan 2007
    Location
    Southern California
    Posts
    7,097
    Liked
    5 times
    If you are trying to force a non-www on the second code block, insert what Brian showed you right after the rewritebase.
    The Forum Hosting - Forum Hosting from the Forum Experts

  3. #3
    MTD
    MTD is offline
    Senior Member
    Real Name
    Mike
    Join Date
    Apr 2008
    Posts
    141
    Liked
    0 times
    Okay, how do I format it since the WP is at example.com/blog/? Do I have to do something like this?

    RewriteCond %{HTTP_HOST} ^www\.example\.com\blog\$
    RewriteRule ^(.*)$ http://example.com/blog/$1 [L,R=301]

  4. #4
    Senior Member
    Real Name
    Ceri May
    Join Date
    Jul 2009
    Location
    United Kingdom
    Posts
    1,726
    Liked
    15 times
    Blog Entries
    1
    Quote Originally Posted by creditcardforum View Post
    Okay, how do I format it since the WP is at example.com/blog/? Do I have to do something like this?
    It would just be

    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^(.*)$ http://example.com/blog/$1 [L,R=301]
    that you need to place in the .htaccess folder in the blog directory.

  5. #5
    MTD
    MTD is offline
    Senior Member
    Real Name
    Mike
    Join Date
    Apr 2008
    Posts
    141
    Liked
    0 times
    It would just be
    Code:
    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^(.*)$ http://example.com/blog/$1 [L,R=301]
    Okay thanks, but where do I put it in relation to the other things that are in the WP default htaccess. Something like this?

    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    
    # END WordPress
    
    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^(.*)$ http://example.com/blog/$1 [L,R=301]

  6. #6
    Senior Member
    Real Name
    Ceri May
    Join Date
    Jul 2009
    Location
    United Kingdom
    Posts
    1,726
    Liked
    15 times
    Blog Entries
    1
    Hi,

    No it would need to be above the rest of the WP rules but bellow the RewriteEngine On rule...

    Something like this would work as you don't really need the <IfModule either

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.example\.com$
    RewriteRule ^(.*)$ http://example.com/blog/$1 [L,R=301]
    
    # BEGIN WordPress
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    # END WordPress

Similar Threads

  1. Rewrite Rule für Wordpress Blog
    By WoWGlider in forum Deutsch
    Replies: 4
    Last Post: 07-14-2010, 07:52 AM
  2. rewrite url like a wordpress blog
    By magnaromagna in forum Custom Rewrite Rules
    Replies: 1
    Last Post: 10-28-2008, 08:38 AM
  3. Wordpress blog or vB/vBSEO blog?
    By Kwak in forum General Discussion
    Replies: 6
    Last Post: 12-11-2007, 02:39 PM
  4. Wordpress htaccess + vbseo htaccess
    By chris06 in forum URL Rewrite Settings
    Replies: 1
    Last Post: 11-01-2007, 11:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •