Route Wordpress Blog to Rails Subfolder - Blog Links Not Changed Route Wordpress Blog to Rails Subfolder - Blog Links Not Changed wordpress wordpress

Route Wordpress Blog to Rails Subfolder - Blog Links Not Changed


It sounds like all you need to do is update the URLs in your WordPress site to use the new scheme. The easiest way to do this would be to perform a search and replace in the database:

Search: blog.my_app.comReplace: my_app.com/blog

However there is one caveat. WordPress stores a lot of serialized data in the database. Serialized strings have a defined length so just changing the strings without updating the length will cause problems.

I like to use this utility to update links in WordPress. It will perform a search and replace on the database and it will properly update serialized data. Make sure you have a backup of your database in case things go wrong.


If you're talking about links that you manually entered, then mtinsley's answer is correct. However if you're talking about links that are auto-generated by WordPress, then the answer is even easier! You just have to go into the WordPress admin and change the Site URL to http://my_app.com/blog/.

HOWEVER, there is a big caveat with this. You are trying to bring along your "link juice". If blog.my_app.com/some/post doesn't redirect to my_app.com/blog/some/post then you will not keep your link juice.

To fix that, you will want to set up htaccess rules or find a WordPress plugin that automatically creates redirects from blog.my_app.com/some/post to my_app.com/blog/some/post. Also, make sure that blog.my_app.com continues to resolve to your blog site during the transition.


Actually, this is one of the things that annoys me most about Wordpress. It's really not designed to be moved. There are settings and internal links scattered all over the database that are specified absolutely instead of relative to the Wordpress base. This makes it a pain in the ass when you want to do something every professional website should do: set up a staging instance, and move it to the live server only when you have everything set up right.

Fortunately, there's an excellent tool to solve this problem:https://interconnectit.com/products/search-and-replace-for-wordpress-databases/

It does a database-wide search and replace that automatically solves the problem with PHP serialized values that arises if you try to do it on your own. You can restrict it to only certain tables, and you can preview the changes it will make before executing them. Whenever you move a Wordpress installation, use this tool to search for the old URL and replace it with the new one.