0
votes

Noticed that by default wordpress keeps the site name www.mysite.com/wordpress but we wanted to change it to www.mysite.com/blog. Based on the documentation and other stackoverflow posts, it's as simple as making following changes.

  1. override WP_SITEURL and WP_HOME in wp-config.php
  2. Fix .htaccess entries to have correct rewrite rules
  3. Update Permalinks settings

Or manually update wp_options table if you are unable to get into WP admin console.

Also followed all the steps mentioned here but still no luck, getting 404 errors when going to the new URL.

2
If you change serialized content in the database, and the strings aren't exactly the same length, PHP will white screen of death you.Brian Gottier

2 Answers

1
votes

Wordpress keep URL information in database. You need to update them as well. Perform search and replace into your DB to replace your existing URL with the new one :

UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';

UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');

UPDATE wp_postmeta SET meta_value = replace(meta_value,'Existing URL','New URL');

UPDATE wp_usermeta SET meta_value = replace(meta_value, 'Existing URL','New URL');

UPDATE wp_links SET link_url = replace(link_url, 'Existing URL','New URL');

UPDATE wp_comments SET comment_content = replace(comment_content , 'Existing URL','New URL');

NB : wp_ change it to your wordpress installation prefix

You can also use this to go faster : https://rudrastyh.com/tools/sql-queries-generator. There is also some WP Plugins to perform search and replace within your WP DB.

0
votes

For some reason none of the approaches including what Hugo mentioned above didn't work for me. I then renamed the root WP installation directory from 'wordpress' to 'blog' to math the URL and everything is working now.

I am not sure why I had to do this but it seems to be working fine now.