Bad replacement of URLs in CSS
-
Line 411 of fvm.php;
–$css = str_ireplace($wp_domain, $fvm_cdn_url, $css);
+$css = str_ireplace($wp_domain . '/wp-content/uploads', $fvm_cdn_url, $css);
-
This is not incorrect.
That line replaces the domain with the cdn domain, when needed.
The code you want to replace, would break the plugin by replacing the domain + uri path, with the cdn domain.fvm_get_protocol
also duplicates CDN url subdomains.# return $result = $default_protocol.$url; $result = str_replace('static.static.','static.',$result); // hack return $result;
My CDN is ‘static.domainnamehere.com’, the subdomain is duplicated for some reason.
- This reply was modified 4 years, 4 months ago by youngcp.
Together these two changes fix my site’s problems.
YMMV
- This reply was modified 4 years, 4 months ago by youngcp.
State the problem you have exactly, and I may be able to help.
The above doesn’t make sense… you must be misconfiguring something on your end.Not all sites use ‘/wp-content/uploads’ as well… so this cannot be applied.
Since you’re active right now, I’ll undo the changes have you look here;
Ok, changes are undone.
The paths for the CDN are wrong, my settings for the paths are as follows;
CDN URL: static.clearpathaction.org
Cache path: /mnt/efs/web/clearpathaction.org/public/wp-content/uploads
(copied from default)Cache url: https://static.clearpathaction.org/
(default: https://static.clearpathaction.org/wp-content/uploads)Tell me once you got a look and I’ll fix the
fvm_get_protocol
to fix thestatic.static.
subdomain, then you can take a look the CSS where it fails to properly update the path for the custom icon font (there should be an elephant in the middle instead of the ubiquitous square box indicating a missing character).Woops I think the purge occurred before both fixes were undone… re-purging.
The subdomain fix was still in but the icon font paths were broken.e.g. https://static.clearpathaction.org/wp-content/uploads/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf
should be; https://static.clearpathaction.org/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf- This reply was modified 4 years, 4 months ago by youngcp.
Cache is being finicky about being purged quickly, since the cache is on the CDN;
https://clearpathaction.org/legislation/ shows the problem with the generated CSS URLs;
Again, ping back as soon as you have had a look, I’d like to re-make my changes temporarily until you can suggest a code solution or configuration change.
Now wrong cache URLs visible on the home page after most recent purge.
No, just write down exactly, what’s needed to reproduce the issue.
Site Url:
CDN domain:
FVM CDN relevant configs (screenshot):Looking at
https://static.clearpathaction.org/wp-content/uploads/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf#1594393214
returning a 403 error, this looks like some misconfiguration on cloudfront, as it’s not fetching correctly from the origin. Your paths are likely not correct.static.clearpathaction.org must mirror exactly, clearpathaction.org
That means,
https://static.clearpathaction.org/wp-content/uploads/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf#1594393214
has to return the exact same content as
https://clearpathaction.org/wp-content/uploads/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf#1594393214
If it’s not, you are doing it wrong.
The paths after static.example.com must match example.com
The cdn replacement will simply replace one subdomain with the other.If you are getting
static.static.example.com
and you only havestatic.example.com
on the cdn field, then most likely your server is returning your url asstatic.example.com
on the$domain
variable.The
$domain
variable comes directly fromsite_url();
and just trimmed from slashes and scheme. https://developer.www.ads-software.com/reference/functions/site_url/So if you have
static.example.com
coming out of$domain
orsite_url();
you likely have something wrong going on on your setup. Those should return your live url, not the cdn url.I know some hosting providers add some php code to rewrite the domain name with “whatever domain/subdomain is requested” so that their staging version works in any subdomain.
Or maybe you use some sort of reverse proxy that overwrite the domain, but the point is…
site_url();
must return your domain, not your cdn url.Another possibility, some other plugin is overwriting that.
https://static.clearpathaction.org/wp-content/uploads/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf is not a misconfiguration, it is an incorrect URL.
https://static.clearpathaction.org/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf is the correct URL. Note the absense of
/wp-content/uploads
$domain or site_url(); return https://clearpathaction.org
https://static.clearpathaction.org/wp-content/uploads/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf is not a misconfiguration, it is an incorrect URL.
https://static.clearpathaction.org/smile_fonts/ClearPathAction2015/ClearPathAction2015.ttf is the correct URL. Note the absense of /wp-content/uploads
Yes, but that’s wrong…
You must have the same uri path on the cdn a you have on the main site.
The plugin only replaces the domain name.The path stays the same.If you want a different path on the cdn than the one on the live site, then the plugin doesn’t support that. I don’t think also, any (or the majority at least) of cdn /cache rewriting plugins will support that either.
- The topic ‘Bad replacement of URLs in CSS’ is closed to new replies.