Hello, I was wondering if anyone might be able to assist with this. I am launching my new site and have uploaded my old site's images to a directory with the same name on the new site. Unfortunately the old site took each image and appended a query string, so now I am trying to come up with ONE redirect to match them all to the location on the new site. The directory they are located in is /d/ and the base image file name with remain the same on both sites.
The problem is that I had to truncate the image file names on the new server, so for example:
http://example.com/d/filename&g2_itemId=012345
now becomes:
http://example.com/d/012345-filename.jpg
So when a request is made for a file in the /d/ directory of any name and with a query string of up to any five number combination it will redirect to the /d/ directory on the new server and find the same image with the rewritten filenames there. What I do not know how to do is to transfer two parameters, one from the original filename and other the appended ID#. This is my attempt at the the rewrite rule...Any help is appreciated!
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/d/([a-z0-9/-]+)$
RewriteCond %{QUERY_STRING} ^g2_itemId=([0-9]*)$
RewriteRule ^(.*)$ http://example.com/d/$2\-$1\.jpg [QSD,L,R=301]
</IfModule>
[edited by: ichthyous at 5:01 pm (utc) on Aug 23, 2016]