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

CDN Linker Plugin

subdreamersubdreamer San Jose, CA
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

  • Options
    R_JR_J Ex-Fanboy Munich 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

  • Options
    R_JR_J Ex-Fanboy Munich 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?

  • Options
    subdreamersubdreamer San Jose, CA

    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.

  • Options
    R_JR_J Ex-Fanboy Munich 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

  • Options
    subdreamersubdreamer San Jose, CA

    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.