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
4
  • What is the environment where you are using the regex? Commented Jan 18, 2023 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. Commented Jan 19, 2023 at 7: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. Commented Jan 19, 2023 at 18:44
  • Please see link to the plugin documentation. If you could help it would be very much appreciated. docs.wp301redirects.com/article/307-regex-redirects-recipes Commented Jan 21, 2023 at 18:22

1 Answer 1

0

You can try this:

/components/com_mijoshop/opencart/image/cache/(?'path'.*)-365x365.jpg /wp-content/uploads/nc/[path].jpg
1
  • Thanks so much, that worked perfectly! Commented Jan 24, 2023 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .