Instead of using find and replace, use the correct methods on URL to change the file name and extention.