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? Jan 18 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. Jan 19 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. Jan 19 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 Jan 21 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! Jan 24 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.