WordPress.org

Ready to get started?Download WordPress

Forums

.htaccess Redirect Question (4 posts)

  1. wpressie
    Member
    Posted 6 years ago #

    Hey everyone,

    This is the scenario. index.html in the root, WP installed in /blog.

    I normally install WP in the root and use the following code in the root .htaccess file to redirect all non-www traffic to www:

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

    My question is, how do I do the same thing with my URL's now that WP is installed in a subfolder?

    Many thanks in advance!

    Mick

  2. wpressie
    Member
    Posted 6 years ago #

    Anyone?

  3. moshu
    Member
    Posted 6 years ago #

    Take out the www part from "WordPress begin" section, and WP will rewrite only what is in between Start and End.
    Don't forget, your WP htaccess MUST be in the subfolder where you installed WP.

    Another way would be to edit the lines
    RewriteBase /whatever
    and
    RewriteRule . /whatever/index.php [L]

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    What moshu said:

    1. Edit the .htaccess in your wordpress folder to not have the www lines. Then update your permalinks so that WordPress will rewrite the .htaccess file correctly. It will be different now that it's in a subfolder.
    2. Make an .htaccess in the root with only those www lines.

Topic Closed

This topic has been closed to new replies.

About this Topic