Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

CDN Linker Plugin

edited March 2016 in Vanilla 2.0 - 2.8

How hard would be to create a CDN linker plugin for Vanilla 2.2+? I use the CDN Linker for WordPress which it's a must have if you run a WP site with a CDN. Check it out: https://github.com/wmark/CDN-Linker

CDN Linker modifies links pointing to ‘wp-content’ and/or ‘wp-includes’ (or whatever you configure) by replacing your ‘blog_url’ with a custom one. Enables you to pull static files, such as images, CSS or JS, from a different host, mirror or CDN.

You could upload your files to S3, CloudFront, MaxCDN or a host dedicated to serving static files.

I am willing to donate (for community) or pay (for my use) to have this created. It would be very beneficial... Any takers? Send me a PM! Thank you!

Tagged:

Best Answer

  • R_JR_J Admin
    Answer ✓

    Answering questions here is fun! If not I wouldn't do it. It's only that a) I cannot test RewriteRules since I'm using nginx and not apache and b) I haven't done that anytime before. I only know in theory how it should work...

    You've asked for a plugin that changes the posts. That would be one option. The other one would be to let your server handle the transformation. Whenever a file with a given pattern is asked for, direct the user to another file.

    That's how a RewriteRule works: all requests are matched against a regular expression pattern and the request is changed if the pattern matches.

    Imagine you have the following file: yourserver.com/wp-content/any.gif. Whenever someone wants to access that file he should be redirected to your cdn server www.cdn.com/YourID/images/any.gif

    Your RewriteRule for that would look like that (I've made it usable for some image types, not just gifs):
    RewriteRule ^/wp-content/(any\.(png|gif|jpg|jpeg))$ https://www.cdn.com/YourID/images/$1 [R,L]

    "R" is a flag to mark this as a temporary redirection, "L" is a flag to tell apache to stop preceeding after that rule has matched.

    Be sure to have RewriteEngine on somewhere above in your htaccess.

    I don't know if this will work, but it should be close to a working solution at least. Look for pages like that to get more info/knowledge: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

Answers

  • R_JR_J Admin

    Shouldn't it be quite easy to solve something like that with a htaccess rewrite rule?

    Or maybe already the built in custom routes?

  • Hmmm... Thanks for taking the time to answer. Would you be kind enough to give me a few examples? If it's bothersome, then don't. I know it must get tired rather quick with all of us forum users asking for peer support.

  • R_JR_J Admin
    Answer ✓

    Answering questions here is fun! If not I wouldn't do it. It's only that a) I cannot test RewriteRules since I'm using nginx and not apache and b) I haven't done that anytime before. I only know in theory how it should work...

    You've asked for a plugin that changes the posts. That would be one option. The other one would be to let your server handle the transformation. Whenever a file with a given pattern is asked for, direct the user to another file.

    That's how a RewriteRule works: all requests are matched against a regular expression pattern and the request is changed if the pattern matches.

    Imagine you have the following file: yourserver.com/wp-content/any.gif. Whenever someone wants to access that file he should be redirected to your cdn server www.cdn.com/YourID/images/any.gif

    Your RewriteRule for that would look like that (I've made it usable for some image types, not just gifs):
    RewriteRule ^/wp-content/(any\.(png|gif|jpg|jpeg))$ https://www.cdn.com/YourID/images/$1 [R,L]

    "R" is a flag to mark this as a temporary redirection, "L" is a flag to tell apache to stop preceeding after that rule has matched.

    Be sure to have RewriteEngine on somewhere above in your htaccess.

    I don't know if this will work, but it should be close to a working solution at least. Look for pages like that to get more info/knowledge: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

  • Thanks, @R_J! I'll check it out. If not, I'll see if I can tweak the Cloudflare plugin to work with MaxCDN.

Sign In or Register to comment.