Title: URL Rewrite using str_replace
Last modified: November 16, 2022

---

# URL Rewrite using str_replace

 *  Resolved [jppinto](https://wordpress.org/support/users/jppinto/)
 * (@jppinto)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/url-rewrite-using-str_replace/)
 * I use the following to redirect to a CDN , it works fine on WordPress images 
   and anything in uploads on posts or pages but does not work on woocommerce images.
   I tried to replace “the_content” with “woocommerce_content” it did not work.
 *     ```
       function replace_text_wordpress($text) {
       	$text = str_replace('domain.com/wp-content/uploads/', 'domain.s3.amazonaws.com/uploads/', $text);
       	return $text;
       }
       add_filter('the_content', 'replace_text_wordpress');
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [jppinto](https://wordpress.org/support/users/jppinto/)
 * (@jppinto)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/url-rewrite-using-str_replace/#post-16203021)
 * I got this working by adding the same filter for woocommerce_single_product_image_thumbnail_html
   and woocommerce_product_get_image
 *  [Saif](https://wordpress.org/support/users/babylon1999/)
 * (@babylon1999)
 * [3 years, 6 months ago](https://wordpress.org/support/topic/url-rewrite-using-str_replace/#post-16212194)
 * Hello [@jppinto](https://wordpress.org/support/users/jppinto/),
 * Glad to hear you’ve figured it out and thank you so much for the update! This
   will help anyone land on the thread in the future. 😃
 * I will go ahead and make the thread as solved, please feel free to create a new
   one if you have any other questions.
 * Cheers!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘URL Rewrite using str_replace’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [cdn](https://wordpress.org/support/topic-tag/cdn/)
 * [str_replace](https://wordpress.org/support/topic-tag/str_replace/)
 * [url rewrite](https://wordpress.org/support/topic-tag/url-rewrite/)

 * 2 replies
 * 2 participants
 * Last reply from: [Saif](https://wordpress.org/support/users/babylon1999/)
 * Last activity: [3 years, 6 months ago](https://wordpress.org/support/topic/url-rewrite-using-str_replace/#post-16212194)
 * Status: resolved