Internal 500 error after directory renaming

Today in one client’s web hosting (it is Nexcess, but same problem can appear in another hostings using the same technology) i needed to rename WordPress home directory. (It was installed in a sub-directory)

I renamed directory, then modified .htaccess file, and then i changed siteurl and home options in wp_options table.

These simple steps above are quite enough for making WP to work in new directory. But i started getting strange errors instead.

Fatal error: require_once(): Failed opening required ‘/chroot/home/sitename/OLDNAME/wp-blog-header.php’ (include_path=’.:/opt/…/php’) in /chroot/home/sitename/OLDNAME/wp-blog-header.php on line 52

I have checked cache layers (all cache layers were turned off at that time) and configurations. Nothing wrong. Everything was provided correctly. Then i tried to print directory name before the line

require( dirname( FILE ) . ‘/wp-blog-header.php’ );

at index.php file. After saving and testing i saw that above error was solved and i started getting the same error for another file:

Fatal error: require_once(): Failed opening required ‘/chroot/home/sitename/OLDNAME/wp-load’ (include_path=’.:/opt/…/php’) …

This time wp-load.php can’t be loaded. At this time i figured out that there is some hosting based software which can’t be refresh itself after renaming directory (BTW, apache or httpd restart doesn’t help in this case) – but if you modify the file, it pings that software and that file starts to be recognized by webserver.

So there were two ways in order to solve the problem under those conditions.

  • To modify thousands of WP files one by one – which would be stupid time wasting.
  • To send some “ping” to all files. – That’s what i did. I opened SSH command line and run this command:

find -type f -exec touch {} +

This command doesn’t modify any file, it just modifies their timestamp data which is quite enough in our case.

After running this command the website started working normally under its new name.