Avoiding WordPress URL breakage

wordpress-logo-hoz-rgbA couple of people have asked me how to recover from a slip of the mouse when using the WordPress administration interface.

Call them flaws in WordPress’s admin design, but the world won’t end if you happen to do either of the following.

  1. Change the default path
  2. Change the permalink URL

Both of these settings can be found in Settings -> General and Settings -> Permalinks respectively in the administration area. Both DO NOT warn the user that if their server settings are not correct changing the values will result in a site that doesn’t display – including the administration area that uses the same URLs.

NOTE: A friend tells me that the second of these only happens with a certain setup of Apache HTTP server. In any case, if it happens to you this method should help restore WordPress.

Change of default path

If you do happen to change the default path from, say, site.to.you.blog to site.to.your.blog/blog/ then you need to have all the WordPress files in that directory for it to work properly. If you don’t, you’ll break your site and be unable to recover it from the admin area as the path value has been changed in the database. There’s a page on the WordPress wiki devoted to moving WordPress.

If you have access to the MySQL server through PHPMyAdmin or the console simply restore the “option_value” value to the original site URL (the one before you changed it) in the wp_options table of your WordPress database. This should get everything working again.

Change of default permalink URL

If you want a more human-readable URL for your blog posts WordPress has a number of predefined permalink settings to choose from in the administration area. If you change the default permalink setting to another your site might not display. This is because WordPress writes a .htaccess file with new rewriting rules for the Web server. The text in the .htaccess file will look like this:

# BEGIN WordPress

<IfModule mod_rewrite.c> RewriteEngine On

RewriteBase /

RewriteRule ^index\.php$ – [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

</IfModule>

# END WordPress

To restore things, simply delete the new permalink entry in the wp_options table and then delete (or overwrite with blank text) the .htaccess file in the /wordpress directory (or wherever WordPress is being served from) on your Web server. To do this you will need ftp or console access to the server and the ftp client (like FileZilla) should be able to view “hidden” files which begin with a “.” dot.

It can be frustrating when a simple change breaks your blog. Maybe one day WordPress will include big fat warnings not to change these settings unless they will bring about the desired result.

About the author

IANAE! (I am not an epidemiologist)

Leave a Reply

Your email address will not be published. Required fields are marked *