This is one of those niggling little problems I had this week. I usually build a Joomla site in a temporary directory of the domain it is going live on then move it to the root directory once the site launches. The normal process involves changing the temporary location in the Joomla configuration file and if you’re running Virtuemart e-commerce, change the directories in Virtuemart’s configuration file too, then move the site to the root directory.
However this week when I thought it had all gone smoothly, it appeared that secondary and additional product images were not showing up when enlarged. It turns out they were still being referenced in the old directory.
A look at the database told me that the full URL for the large version of secondary images/files had been coded into the database for every image meaning that when I moved the site, the URL’s were then pointing at empty locations.
There were two ways I could think of to solve this:
1. Use a redirect on the images directory. I just added this line at the end of the .htaccess file:
redirect 301 /temp_dir/components/com_virtuemart/shop_image/product/ http://www.domain.com/components/com_virtuemart/shop_image/product/
2. Use phpMyAdmin on your server and go through each row in the jos_vm_product_files table and edit to put the new location in the file_url field. If you’ve got a lot of images, this can take a while.
For the moment, both ways seem to work.