Remove absolute url (schema, host name) from f= paths
-
This plugin should be modified to remove schema and host from the input file paths when an input path matches the current schema and host.
I believe this will cover a number of issues that arise when themes or plugins are poorly coded. For others, it will have zero effect.
-
BWP Minify should already be doing so (there’s a bug with external media files though). Could you please point me to a theme or a plugin that is causing this issue?
It’s possibly this problem only reveals itself when you run wordpress as a submodule. For those of us who do this (git users) our directory structure looks like this:
/wordpress (unmodified submodule)
/wp-contentI am looking into this right now.
I didn’t have a lot of time to fix this so my solution was to simply filter and overwrite $_GET[‘f’] directly in bwp-minify/min/index.php. I also included the following filter class there, for reference:
class BWPMinify_FilesInputFilter { public static function absoluteLocalize($f, $exclude_port = false) { if (empty($f)) return $f; // not sure who is responsible for this $_filter_uri = str_replace('://', ':/', self::__uriRoot($exclude_port)); $_f_parts = explode(',', $f); $_result_paths = array(); foreach ($_f_parts as $_f_path) { $_result_paths[] = str_replace($_filter_uri, '', $_f_path); } return implode(',', $_result_paths); } private static function __uriRoot($exclude_port = false) { $s = $_SERVER; $ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true : false; $sp = strtolower($s['SERVER_PROTOCOL']); $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : ''); $port = $s['SERVER_PORT']; $port = ((!$ssl && $port == '80') || ($ssl && $port == '443') || $exclude_port) ? '' : ':' . $port; $host = isset($s['HTTP_X_FORWARDED_HOST']) ? $s['HTTP_X_FORWARDED_HOST'] : isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : $s['SERVER_NAME']; return $protocol . '://' . $host . $port; } }
In /bwp-minify/min/index.php you will see an existing comment “// serve!” — under this line I simply filter $_GET[‘f’]
$_GET['f'] = BWPMinify_FilesInputFilter::absoluteLocalize($_GET['f'], true);
I should add: I discovered something quite strange in that the local css files that were being passed to min/index.php?f= had bad url schemes. There was only a single slash like http:/domain.com/file/etc.css.
I’m wondering if this was the actual problem and if it’s being caused by something else?
Hmm you are running WordPress as a submodule? That’s interesting. This is your current setup:
wordpress (config, wp-includes, etc.)
wp-content (plugins, cache, etc.)
index.phpright?
Yes, fairly similar to this: http://ajk.fi/2013/wordpress-as-a-submodule/ — the idea is to keep /wordpress free of any changes. It allows you to checkout tags for new versions and test against them before committing to a wordpress update.
Do you know what would cause the single slashes in the f= value? This seemed unusual to me.
This looks like the same issue I reported awhile back although I haven’t had time to dig into it further:
http://wordpress.org/support/topic/does-not-work-with-wordpress-in-its-own-directory?replies=1
https://github.com/OddOneOut/Better-WordPress-Minify/issues/5
Same issue here. http://143.95.39.117/~tunxised/
Moving a college site from a local server to a 3rd party host, so right now DNS is not pointed and I’m using a temp URL.
The BWP links should be getting written as:
http://143.95.39.117/~tunxised/wp-content/plugins/bwp-minify/min/?f=wp-content/themes/tunxiscc/js/404.jsbut instead they’re being written as
http://143.95.39.117/~tunxised/wp-content/plugins/bwp-minify/min/?f=~tunxised/wp-content/themes/tunxiscc/js/404.jsThe other problem was that the document root wasn’t set properly, but I manually fixed that in the config.php file.
Any suggestions?
I added this to wp-config, so now those work, but it’s a hack i’d liek to not do if possible: $_GET[‘f’] = str_replace(‘~tunxised/’, ”, $_GET[‘f’]);
Please follow updates here:
https://github.com/OddOneOut/Better-WordPress-Minify/issues/7Version 1.3.0 will fix this bug.
Hey guys please check out version 1.3.0-beta and see if it fixes this issue: https://github.com/OddOneOut/Better-WordPress-Minify/archive/1.3.0.zip
Also @james in your case
~tunxised
is considered abase
so the second URL is actually the correct one, it must have?f=~tunxised
, Minify will complain if thebase
is missing.Thanks Khang Minh!
It seems I was fancing the same problem and the beta version fix it.
The error on firebug was
404 Bad Request http://my.site.com/wp-content/plugins/bwp-minify/min/?f=http:/my.site.com/wp-content/themes/my-theme/style/custom.css
(Note the single slash after protocol on “f” parameter)
And the error on FirePHP was
Minify: The path "/root/www//http:/my.site.com.br/wp-content/themes/my-theme/style/custom.css" (realpath "") could not be found (or was not a file)
(Note the protocol and hostname in the path string)
Now seems everything works well
- The topic ‘Remove absolute url (schema, host name) from f= paths’ is closed to new replies.