Im sure there must be a clever way round this but I just cant figure it out. I am using mod_rewrite to create SEO friendly filenames AND switch to our CDN. I can do them both seperately but together they cancel eachother out
We use mod_rewrite (in htaccess) to create SEO friendly filenames. So for example :-
RewriteRule ^thumbnails/([0-9]+)/([^/]+).jpg$ /thumbnails/$1/image.jpg [NC,L]
maps https://www.example.com/thumbnails/123/my-image-of-a-puppy.jpg onto https://www.example.com/thumbnails/123/image.jpg
That all works fine. But we also use mod_rewrite to pull the images from the CDN so we use something like this :-
RewriteRule ^(.*).(jpeg|jpg|png)$ https://cdn-w.example.com%{REQUEST_URI} [R=301,NC,QSA,L]
Now mod_rewrite does an external 301 redirect (or 302 if i leave out the R=301 bit).
That all works fine too but as far as google is concerned, https://www.example.com/thumbnails/123/my-image-of-a-puppy.jpg simply gets redirected to https://cdn-w.example.com/thumbnails/123/image.jpg which cancels out the SEO friendly filename doesnt it ??
Am I missing something ?