Question

I have link like this: www.my-site.com/full-image/folder/subfolder/image-name.jpg-some-custom-keywords.html

and I need 301 redirection to url like this:

www.my-site.com/folder/subfolder/image-name.jpg.html?some-custom-keywords.html

I need to remove "full-image/" and to change ".jpg-" to ".jpg.html?"

I managed to write url redirection to remove "full-image/" like this:

RewriteRule ^full-image/(.*)$ /$1 [L,R=301]

By the way is this rewrite rule best way? (it works)

But how to change ".jpg-" to ".jpg.html?"

Best regards.

Was it helpful?

Solution

Try this rule:

RewriteRule ^full-image/(.+?\.jpg)-(.*)$ /$1.html?$2 [L,R=301,NC]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top