Problem Redirecting Subdomain to Subdirectory (after moving WordPress blog)

Discussion in 'Apache' started by sherryl, Oct 30, 2012.

  1. #1
    I had a static site with a WordPress blog in a subdomain. When I created a new site in WordPress, I installed WordPress in a subdirectory. I then forwarded the subdomain blog.example.com to example.com/blog. That works if someone is looking for the old home page of the blog. (They’re directed to the new blog home page.) My problem is that I haven’t been able to figure out how to redirect individual posts that used to be in blog.example.com (for example, blog.example.com/post1). If someone clicks on an old link, they end up with a 404 page-not-found error.

    I would be extremely grateful to anyone who can help me. I’ve been researching this for days and I have tried multiple suggestions to modify my .htaccess but I don’t really understand how to get this to work.
     
    sherryl, Oct 30, 2012 IP
  2. sherryl

    sherryl Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Thanks to a blogging friend (who really understands Apache redirects) for writing this new .htaccess file. It works perfectly.
    
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule (.*) http://www.example.com/blog/$1 [R=301,NC]
    Code (markup):
    I hope this helps someone else. (By the number of views that this thread has had already, I think it may.)
     
    sherryl, Nov 3, 2012 IP