WordPress.org

Ready to get started?Download WordPress

Forums

How to set htaccess correctly when I move my blog to new directory? (3 posts)

  1. WPChina
    Member
    Posted 6 years ago #

    My blog is currently located in the root of my site at http://www.myblog.com but I want to move it to http://www.myblog.com/blog/. I understand how to move it into the new directory and how to reset the links on the blog to show the new directory of /blog/ but I still have a problem:

    How can I setup an htaccess so that anybody coming to the old link in the root at myblog.com/%year%/%monthnum%/%day%/%postname%/ can now go to myblog.com/blog/%year%/%monthnum%/%day%/%postname%/ ?

    Thank you for your guidance!

  2. WPChina
    Member
    Posted 6 years ago #

    OK, I set this up and it works:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)$ http://www.myblog.com/blog/$1 [R=301L]]
    </IfModule>

    However, I still have one very important problem to work out. Now that the old blog links are pointing to the new blog links, I also want to do something unorthodox. I have another directory that I want to make the main section of my entire website, and it currently resides at http://www.myblog.com/gallery

    I want to make people coming to http://www.myblog.com to instead be forced to go to http://www.myblog.com/gallery.

    So do you follow me on all this? I want to do 2 things, and the first thing is already working:
    1) point myblog.com/%year%/%monthnum%/%day%/%postname%/ to myblog.com/blog/%year%/%monthnum%/%day%/%postname%/
    2) If anybody goes directly to http://www.myblog.com (the old homepage of the entire site), they will instead go to http://www.myblog.com/gallery/

    For the second idea above, I tried this code:

    Redirect 301 /index.php http://www.myblog.com/gallery/

    If I use that ALONE (without the RewriteRule code I mentioned at the very beginning), it works fine. However when I use the code for #1 and #2, only the #1 code works and the #2 code doesn't work at all...

    Any ideas?

  3. WPChina
    Member
    Posted 6 years ago #

    Sorry to bounce, but this is a headache to figure out. I'm sure it's a matter of 1-2 lines of code in htaccess, but the more I ply around with it, the more combinations I find that continue to ruffle my feathers.

Topic Closed

This topic has been closed to new replies.

About this Topic