WordPress.org

Forums

.htaccess (?) redirect help needed for moved WP install (10 posts)

  1. moshu
    Member
    Posted 9 years ago #

    I used to have a WP install at mydomain.com/wp.
    The blog has been moved to subdomain.mydomain.com/blog.

    There are quite a number of incoming links to the old address. Is there any possibility to set up some .htaccess magic to redirect those links to the new location?
    The blog is using the same permalink structure in both places:
    archives/year/month/day/post-title

    Any .htaccess guru out there? Thanks.

  2. jwilliams
    Member
    Posted 9 years ago #

    an easy solution might to delete the ./wp directory, and then

    $ ln -sf ./blog wp;

    then you have a blog dir and a filesystem link wp to ./blog,
    so when apache calls wp it gets stuff out of ./blog.

  3. moshu
    Member
    Posted 9 years ago #

    Thanks, but I am afraid you will have to be more explicit - consider me totally illiterate in this matter.
    And just in case you missed:
    old address - mydomain.com/wp
    new address - subdomain.mydomain.com/blog

  4. jwilliams
    Member
    Posted 9 years ago #

    Ah, yes, I didn't notice the subdomain part. I'll get back later.

  5. moshu
    Member
    Posted 9 years ago #

    Thanks, jwilliams.
    Maybe in the meantime somebody can give me some detailed instructions :)

  6. jwilliams
    Member
    Posted 9 years ago #

    what is the absolute local path to your document root for domain.com,
    and what is the absolute local path to your document root for subdomain.domain.com ?

  7. niziol
    Member
    Posted 9 years ago #

    Moshu,

    I use this redirect rule in my .htaccess, it would redirect any request for the old address to the new. I don't use it with a sub domain, but I have used a similar rule in the past to completely different domains and it worked well:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^wp/(.*)$ http://sub.example.com/$1 [R=301,L]

    Just add all of that (or just the rule on the last line) to your .htaccess and give it ago. The above assumes the .htaccess will be in the root www directory. I'm not sure if it's the best or not, but it works for me!

    Good luck,
    Michael.

  8. moshu
    Member
    Posted 9 years ago #

    /home/**myusername**/public_html/
    and
    /home/**myusername**/public_html/subdomain/

  9. niziol
    Member
    Posted 9 years ago #

    This should do it for you then moshu:

    RewriteEngine On
    RewriteBase /
    RewriteRule ^wp/(.*)$ /*subdomain*/$1 [R=301,L]

    Just change the *subdomain* to your intended subdomain and place the code (either all of it or the rewrite rule) into the .htaccess in your root (/home/*username*/public_html) directory or adjust the paths accordingly.

    Cheers,
    Michael.

  10. moshu
    Member
    Posted 9 years ago #

    Thanks, Michael, I'll give it a try.

Topic Closed

This topic has been closed to new replies.

About this Topic