treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Redirecting old permalink structure to the new one

  • Hey!

    I had a wordpress site installed in a sub folder with category/post-title permalink structure, which resulted in the following url structure

    http://www.mysite.com/subfolder/category/post-title

    However as I needed to move my site to the root folder on another server and changed the permalink structure to year/month/post-title, which looks like below, users who visit my website through the links published on other websites see 404 error page as expected.

    http://www.mysite.com/year/month/post-title


    While doing the changes, moving wordpress to the root directory on another server and changing permalink structure, I forgot to take into account that such problem could occur. Anyway, I made a mistake and now I'm trying to fix the problem.

    I wonder is there a way to redirect the old urls to the new ones? Editing .htaccess or using a plugin or something else. The method doesn't matter at this stage. All I want is to solve the problem

    Any help? Thanks in advance.
  • Editing the htaccess is the way to go. A 301 redirect on the affected pages. You can also do it on a PHP basis (assuming it is build on PHP)
  • I've been working on .htaccess file writing various combinations of Rewrite rules. But, as I'm a total newbie when it comes to .htaccess, I've got nowhere.
    I need some code examples to figure out how I write my own code.