SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast kemal's Avatar
    Join Date
    Jan 2005
    Location
    Pennsylvania
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Wordpress and .htaccess

    Hi friends,

    I've got some .htaccess confusion with a WP blog. I have an html site that links to the blog (same domain). I have an .htaccess file in the html root:

    ErrorDocument 404 /not_found.html

    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^(.*)\.mysite\.com$ [NC]
    RewriteRule ^(.*)$ http://www.mysite.com/$1 [R=301,L]
    So, as I understand it, it's good to redirect non www to www.

    Then, I have a blog folder (mysiteblog) that's got all the WP files. In that folder I have another .htaccess:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /mysite.com/mysiteblog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /www.mysite.com/mysiteblog/index.php [L]
    </IfModule>
    However, if i type in the blog address without the www, it doesn't redirect to www. I know I don't have the .htaccess written correctly.... I don't even recall where I found the info to write it as i did...

    Could somebody please help, and, I don't understand this issue, though, it has been suggested to me that it's important to address. I'm not even sure of that.

    Thanks!
    kf

  2. #2
    Is Still Alive silver trophybronze trophy RetroNetro's Avatar
    Join Date
    Jul 2003
    Location
    Texas
    Posts
    6,883
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hello

    This should work:
    Code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www.yoursite.com$ [NC]
    RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R,L]
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php
    </IfModule>
    # END WordPress
    Hope it helps.

    Though just to be on the safe side, you can goto your WP control panel and click the Options>Permalinks decide on what structure you want, then click Update Permalink Structure and it wil spit out some code, copy that and paste it into a .txt editor and then just add:
    Code:
    RewriteCond %{HTTP_HOST} !^www.yoursite.com$ [NC]
    RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R,L]
    After the RewriteEngine On line. Then save it as .htaccess and upload it to the root of your WP install.

  3. #3
    SitePoint Enthusiast kemal's Avatar
    Join Date
    Jan 2005
    Location
    Pennsylvania
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for that Johnny.

    I used this suggestion of yours:

    Though just to be on the safe side, you can goto your WP control panel and click the Options>Permalinks decide on what structure you want, then click Update Permalink Structure and it wil spit out some code, copy that and paste it into a .txt editor and then just add:
    Code:

    RewriteCond %{HTTP_HOST} !^www.yoursite.com$ [NC] RewriteRule ^(.*)$ http://www.yoursite.com/$1 [R,L]

    After the RewriteEngine On line. Then save it as .htaccess and upload it to the root of your WP install.
    The thing is, if you type this into your browser:
    http://mysite.com/myblog
    It redirects to http://www.mysite.com.
    I thought it should be set-up so that http://mysite.com/myblog redirects to http://www.mysite.com/myblog.

    I really don't know if this is how it should be or not. Someone suggested that it should be that way.

    Thank you again!
    kf


Bookmarks

Posting Permissions

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