Title: Plugin rewriting urls
Last modified: October 24, 2017

---

# Plugin rewriting urls

 *  [ericna](https://wordpress.org/support/users/ericna/)
 * (@ericna)
 * [8 years, 5 months ago](https://wordpress.org/support/topic/plugin-rewriting-urls/)
 * This plugin is rewriting my urls. Here is an example:
 * I am able to upload files to my media library and it successfully loads it onto
   s3 and gives me an s3 url to that media item. If I use an uploaded image as a
   featured image it works perfectly fine.
 * However, I also uploaded a pdf and included a link to it in a wysiwyg in one 
   of my sites pages. I see in the edit page that I did indeed paste the s3 url 
   but when I view the page itself the link has been somehow rewritten to point 
   to the wordpress style url [http://www.site.com/wp-content/uploads/2017/10/file.pdf](http://www.site.com/wp-content/uploads/2017/10/file.pdf).
 * I know for a fact that its the plugin causing this behavior. If I deactivate 
   the plugin and insert the s3 url into the edit page then the url does NOT get
   rewritten.
 * Why is this happening? And how can I turn this off? I have seen similar frustrations
   on this message board but nobody seems to have a solution and the plugin developers
   seem to pass the buck and say its not the plugin but it obviously is.
 * Thanks!

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

 *  [jonasnic](https://wordpress.org/support/users/jonasnic/)
 * (@jonasnic)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/plugin-rewriting-urls/#post-9662453)
 * [@ericna](https://wordpress.org/support/users/ericna/) Did you found a solution
   yet?
 * We have the same issue, exactly as you describe.
 *  [dbasantani](https://wordpress.org/support/users/dbasantani/)
 * (@dbasantani)
 * [8 years, 4 months ago](https://wordpress.org/support/topic/plugin-rewriting-urls/#post-9676945)
 * Hi ,
 * I got the same issue with new aws plugins in our multisite environment.
 * I have updated both “amazon-s3-and-cloudfront” and “amazon-web-services”
 * and found the same issue which you guys found but in only one post type related
   with email in our system.
 * what i did to fix that is commented one function call in below file :
 * wp-content/plugins/amazon-s3-and-cloudfront/classes/as3cf-filter.php
 * function name : find_urls_and_replace
    and commented code in this function. ://
   $value = $this->replace_urls( $value, $url_pairs );
 * I still have one issue left with this new plugin when I share post between two
   stations , image in child station comes busted I am still working on that but
   you guys can try above thing and do fresh test and see if that works
    for you
   guys.
 * Thanks,
    Dipak.
 *  [oweux](https://wordpress.org/support/users/oweux/)
 * (@oweux)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/plugin-rewriting-urls/#post-9838126)
 * We had a similar situation in which images hosted on third party websites had
   their urls re-rewritten by this plugin instead of being left alone. I understand
   this is not your particular issue but you may edit as3cf-filter.php and create
   your own code to check for your particular condition and override it. Others 
   might find it useful. This page lead me to the correct file to edit.
 * What we did was add the following:
 *     ```
           protected function should_process_host($url_found, $url_wp){
   
               $src_host_names = explode(".", parse_url($url_found, PHP_URL_HOST));
   
               $src_host_names = array_slice($src_host_names, -2);
   
               $src_host_names = implode('.', $src_host_names);
   
               $wp_host_name = explode(".", parse_url($url_wp, PHP_URL_HOST));
   
               $wp_host_name = array_slice($wp_host_name, -2);
   
               $wp_host_name = implode('.', $wp_host_name);
   
               if ($src_host_names !== $wp_host_name) {
                // OR if(strpos($wp_host_name, $src_host_names))
   
                   return false;
   
               }
   
           }
       ```
   
 * Then add:
 *     ```
                   if (!$this->should_process_host($url, get_site_url())) {
                       // URL is foreign, skip
                       continue;
                   }
       ```
   
 * within the “foreach ($matches as $url)” loop in:
 * get_urls_from_content
    get_urls_from_img_src
 * You may want to adjust “-2” on array_splice depending on how ‘deep’ you need 
   to host comparison.
 * The fix is not ideal because it will get overwritten on each update.
 * _[Moderator note: code fixed. Please wrap code in the backtick character or [use the code button](https://make.wordpress.org/support/handbook/forum-welcome/#post-code-safely).]_
    -  This reply was modified 8 years, 3 months ago by [bdbrown](https://wordpress.org/support/users/bdbrown/).
    -  This reply was modified 8 years, 3 months ago by [bdbrown](https://wordpress.org/support/users/bdbrown/).
    -  This reply was modified 8 years, 3 months ago by [bdbrown](https://wordpress.org/support/users/bdbrown/).

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

The topic ‘Plugin rewriting urls’ is closed to new replies.

 * ![](https://ps.w.org/amazon-s3-and-cloudfront/assets/icon-256x256.jpg?rev=1809890)
 * [WP Offload Media Lite for Amazon S3, DigitalOcean Spaces, and Google Cloud Storage](https://wordpress.org/plugins/amazon-s3-and-cloudfront/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/amazon-s3-and-cloudfront/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/)
 * [Active Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/amazon-s3-and-cloudfront/reviews/)

## Tags

 * [external URL](https://wordpress.org/support/topic-tag/external-url/)

 * 3 replies
 * 4 participants
 * Last reply from: [oweux](https://wordpress.org/support/users/oweux/)
 * Last activity: [8 years, 3 months ago](https://wordpress.org/support/topic/plugin-rewriting-urls/#post-9838126)
 * Status: not resolved