• 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 https://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)
  • @ericna Did you found a solution yet?

    We have the same issue, exactly as you describe.

    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.

    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.]

    • This reply was modified 7 years, 1 month ago by bdbrown.
    • This reply was modified 7 years, 1 month ago by bdbrown.
    • This reply was modified 7 years, 1 month ago by bdbrown.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Plugin rewriting urls’ is closed to new replies.