(This answer assumes a standard setup using MySQL and Apache on linux.)
I'm afraid the best option is to do a manual search-and-replace on your database, replacing /DirectoryName/
with /NewDirectoryName/
(or /
, if your production site does not use a sub directory) in all fields with the WYISIWYG editor enabled. Make sure you search and replace in the field_data tables (like field_data_body
) as well as the field_revision tables (like field_revision_body
).
I guess you could also add a rewrite rule in .htaccess to rewrite old image paths to new ones, but that doesn't really solve the problem and might make your site more difficult to maintain in the future.
To prevent this problem in future projects, make sure you know beforehand what the production URL is going to be. Set up your local environment with a virtual host to mimic the production URL. For instance, if the production URL will be http://www.example.com/, you can use http://dev.example.com/ for your local environment. If you know the site will run in a subdirectory, eg.
http://www.example.com/drupalsite/, set up your local site as http://dev.example.com/drupalsite/.