WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multiple .htaccess files on one website (7 posts)

  1. ajhauser
    Member
    Posted 1 year ago #

    Hello,
    I have WordPress installed in a directory called "wordpress" for my website located at: hauserdesigngroup.com

    (blog here: hauserdesigngroup.com/wordpress/

    You will notice when you click that link that it bumps you over to http://WWW.hauser...

    I have this file in place to add WWW with a 301 redirect to every page:

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

    However, once in the "wordpress" directory, this doesn't work - and I am guesing it's not compatable with the .htaccess for re-writing URLs. I mean if you go to "hauserdesigngroup.com/wordpress/", it doesn't get adjusted to "WWW.hauserdesigngroup.com/wordpress/".

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /wordpress/index.php [L]
    </IfModule>

    Is there a way to combine these two?
    I would just like to make sure the blog section adds "WWW" to every URL like the rest of the site.

    Thanks very much.

  2. jasonrogers.ca
    Member
    Posted 1 year ago #

    Add this into your .htaccess file in you /wordpress directory with this in it

    RewriteEngine on
    Options FollowSymlinks
    rewritecond %{http_host} ^ hauserdesigngroup.com [nc]
    rewriterule ^(.*)$ http://www. hauserdesigngroup.com/$1 [r=301,nc]

    Should solve it I, pretty sure its the best way.

    Jason

  3. No need to add or remove the www in .htaccess or add 301 redirects. Add the www prefix to both URLs in Dashboard>>Settings and save.

    Then get rid of everything else in .htaccess other than the standard WP permalinks block.

  4. ajhauser
    Member
    Posted 1 year ago #

    Awesome - thank you both! The second method mentioned did the trick for all the pages. My only other question is whether or not the first method would work for EVERYTHING, including images. For example, without adding anything to the .htaccess file I can still load this without the "www" added:

    http://hauserdesigngroup.com/wordpress/wp-content/uploads/2012/09/example-of-a-great-qr-code-4.jpg

  5. ajhauser
    Member
    Posted 1 year ago #

    But maybe that doesn't matter either way? Meaning, maybe 301's wouldn't redirect image links?

  6. Nothing is needed to .htaccess for the www issue. Simply add www in WP settings.

    That image link works with and without the www

  7. ajhauser
    Member
    Posted 1 year ago #

    Thanks for all the help! Really appreciate it.

Topic Closed

This topic has been closed to new replies.

About this Topic