0

I am looking for an RegEX redirect rule to redirect the image file locations to a new location, whilst also removing part of the original url which is the name of the image

OLD URL:

/components/com_mijoshop/opencart/image/cache/catalog/ecom2/GM815-365x365.jpg

NEW URL:

/wp-content/uploads/nc/catalog/ecom2/GM815.jpg

So I need to change the directory path AND remove the ‘-365x365’ part of the url.

I can remove the part of the image name with the following, but unsure how to also change the path:

/(?'path'.*)-365x365.jpg  /[path].jpg
Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63
  • What is the environment where you are using the regex? – Tero Kilkanen Jan 18 '23 at 16:28
  • It’s Wordpress, a redirect plugin. We migrated from a really old Joomla site and we have thousands of image urls that have changed that I would like to put 301s on. – Rebecca Hubbard Jan 19 '23 at 07:53
  • Please add link to the plugin to the question, so that we can check the documentation. Without seeing documentation, an answer cannot be given. – Tero Kilkanen Jan 19 '23 at 18:44
  • Please see link to the plugin documentation. If you could help it would be very much appreciated. https://docs.wp301redirects.com/article/307-regex-redirects-recipes – Rebecca Hubbard Jan 21 '23 at 18:22

1 Answers1

0

You can try this:

/components/com_mijoshop/opencart/image/cache/(?'path'.*)-365x365.jpg /wp-content/uploads/nc/[path].jpg
Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63