Minify on Windows == 404 [FIX]
-
On Windows, using the minify with fancy URLs does not work (returns 404) because the slashes added to paths are backwards so strings do not match and the Apache will not accept / as a replacement for \ in htaccess files.
The fix I did:
In /w3-total-cache/lib/W3/MinifyAdminEnvironment.php: Line 382 (first line of rules_core_generate_apache function): Change to:
$cache_dir = str_replace('\\', '/', w3_filename_to_uri(W3TC_CACHE_MINIFY_DIR) );
(added str_replace to convert \ to /)In /w3-total-cache/lib/W3/MinifyAdminEnvironment.php: Line 787 (first line of rules_wpmu_subfolder_generate function): Change to:
$cache_dir = str_replace('\\', '/', w3_filename_to_uri(W3TC_CACHE_MINIFY_DIR) );
(added str_replace to convert \ to /)In /w3-total-cache/inc/define.php: Line 156 (if statement within w3_filename_to_url function): Change to:
if(str_replace('\\', '/', substr(trailingslashit(WP_CONTENT_DIR), 0, strlen(trailingslashit(w3_get_site_root())))) == trailingslashit(w3_get_site_root())) {
(added str_replace to convert \ to /)The last file above (without the str_replace) will return something like C:\path-to-wordpress\sitename\wp-content/ while w3_get_site_root() returns /path-to-wordpress/sitename/. Since the two do not match (the first includes \ directory separators while the second includes / as directory separators) it falls back to the else which is not what you want.
Once I made the changes everything runs fine in Windows (no more 404s).
- The topic ‘Minify on Windows == 404 [FIX]’ is closed to new replies.