404 MIME type issue
-
When installed in subdirectory I get 404 on all minified assets and MIME type issue stylesheets are recognized as text/html.
The htaccess rule when using _static/??/ require to be more dynamic if you changed content folder name viaWP_CONTENT_DIR
andWP_CONTENT_URL
. I did test changing it from wp-content/ in the rewrite rule to just content/ to match without success.RewriteRule ^_static/.* wp-content/plugins/powered-cache/includes/file-optimizer.php [L]
RewriteRule ^_static/.* content/plugins/powered-cache/includes/file-optimizer.php [L]
But somehow must be that _static/??/ path does exist but feels it doesn’t exist which is why the MIME rules not working even I added into the htaccess.
-
Hi @alriksson,
The htaccess rule when using _static/??/ require to be more dynamic if you changed content folder name via?
WP_CONTENT_DIR
?and?WP_CONTENT_URL
. I did test changing it from wp-content/ in the rewrite rule to just content/ to match without success.Using an absolute path instead of relative path would make sense.
But somehow must be that _static/??/ path does exist but feels it doesn’t exist which is why the MIME rules not working even I added into the htaccess.
That’s the purpose of rewrite rules.
Could you try something like this:
RewriteRule ^_static/.* custom-directory/content/plugins/powered-cache/includes/file-optimizer.php [L]
basically point to the physical file location from your .htaccess file.
Please give it a try and let me know.
Thanks for the quick answer @m_uysl
Using an absolute path instead of relative path would make sense.
Ok lets try that what would you add instead of following:
define('WP_CONTENT_DIR', dirname(dirname(FILE)) . '/custom-directory/content');
define('WP_CONTENT_URL', 'https://' . $_SERVER['HTTP_HOST'] . '/custom-directory/content');But relative path feels more to make external plugin like your being able to plug and play.
Tried but still getting:
Refused to apply style from ” because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.Not sure if its related but
/??/
seems to redirect to/?/
https://share.cleanshot.com/X1nZDFszYour configuration looks ok, I mean just update the correct path that points to file-optimizer.php and turn of “Automatically configure .htaccess” option under the advanced options section. (otherwise, your configuration can get overridden)
If it doesn’t work, you can turn off the rewrite feature for file optimizer, which should work with your custom directory structure.
Refused to apply style from ” because its MIME type (‘text/html’) is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Once the 404 issue is addressed, the MIME issue will also be automatically resolved. This is essentially due to the WP 404 page being loaded as js/css assets.
Not sure if its related but?
/??/
?seems to redirect to?/?/
Please make sure other rewrite rules don’t mess with redirections. The url should
/??/
and it’s important to keep file optimizer functioning.Your configuration looks ok, I mean just update the correct path that points to file-optimizer.php and turn of “Automatically configure .htaccess” option under the advanced options section. (otherwise, your configuration can get overridden)
If it doesn’t work, you can turn off the rewrite feature for file optimizer, which should work with your custom directory structure.
Yes that seemed to override it. But that also means any changes you made to configure htaccess I wont get. So once resolved does it make sense to configure the path you add to be relative to support custom dir better?
Once the 404 issue is addressed, the MIME issue will also be automatically resolved. This is essentially due to the WP 404 page being loaded as js/css assets.
True!
Please make sure other rewrite rules don’t mess with redirections. The url should
/??/
and it’s important to keep file optimizer functioning.
Expect from what powered cache is adding this is what I have:
https://pastebin.com/Bh5DicmE
Something you can spot there?But also see that the minified css files doesnt show up in the folder ?? on the server. the JS file seems to.
Is it because if file is already named with min.css or min.js it will be ignored?Yes that seemed to override it. But that also means any changes you made to configure htaccess I wont get. So once resolved does it make sense to configure the path you add to be relative to support custom dir better?
Yes, it makes sense. I’ve opened an issue about that. Meanwhile, htaccess is not updated very often, and you can download the configuration
Misc > Download Configuration
section.Something you can spot there?
I am unable to spot there, but I’m suspicious that your updated rewrite is not working as expected and request is handled by WordPress – which removes one of
?
from the URL.I suggest turning off the automatic htaccess configuration and adjusting the rules with your own custom structure, or alternatively, disabling the “Rewrite File Optimizer” option.
Is it because if file is already named with min.css or min.js it will be ignored?
Yes, if the file contains
.min
it will automatically skipped.Thanks good.
Not sure if its a rewrite issue though? tested disable your css minify and test perfmatters remove unused css and get the same issue.Refused to apply style from '.....com/custom/content/cache/perfmatters/.....com/custom/css/category.used.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
I suggest turning off the automatic htaccess configuration and adjusting the rules with your own custom structure, or alternatively, disabling the “Rewrite File Optimizer” option.
Already turned off the automatic htaccess configuration but disabling Rewrite File Optimizer is also not ideal as not nice file paths here. But either way it is 404
/content/plugins/powered-cache/includes/file-optimizer.php??/content/plugins/frames-plugin/classes/Widgets/slider/js/slider.js&minify=1
To me it looks like they become 404 as the css file is enqueued but not generated as for your folder and perfm, they are both empty no css file there which might explain redirect and then 404.
What with the custom sub directory can cause the plugin not to generate the file?This plugin as example manage to generate css files so maybe checking the source code of that plugin can explain why it doesnt work for powered cache and perfmatters? https://www.ads-software.com/plugins/debloat/
- This reply was modified 1 year ago by Rookie.
There are some static
wp-content
usage in the file-optimizer. https://share.cleanshot.com/kMd56jm0Can you try to change these with your custom directory structure and see if there is any difference?
- This reply was modified 1 year ago by Mustafa Uysal.
@m_uysl
Thanks yes that make it work! But would require a hook and added to documentation for it to not be overridden. But I cannot use the nice rewrite path only the file-optimizer.php?? which doesn’t look nice.Why isn’t it just enqueued as a standard file when its generated? Why handle the hassle with rewrite which as we can see causes issues?
I wanted to try the pro version with the critical css and unused css, is it possible?Thanks yes that make it work! But would require a hook and added to documentation for it to not be overridden. But I cannot use the nice rewrite path only the file-optimizer.php?? which doesn’t look nice.
File-optimizer doesn’t support the use of hooks because it doesn’t load WordPress. However, you have the option to define constants prior to their definition in the file. For example, you can use a custom .user.ini file to load a PHP file containing your custom definitions.
Why isn’t it just enqueued as a standard file when its generated? Why handle the hassle with rewrite which as we can see causes issues?
There’s no need to use rewrite; the appearance of the URL, whether it’s well-structured or not, doesn’t impact its functionality. It will work effectively regardless.
File Optimizer is doing optimizations on the fly, and it’s more efficient for large-scale WordPress installations and it’s able to optimize assets for logged-in users too. (it’s sort of a custom implementation of nginx-http-concat)
I wanted to try the pro version with the critical css and unused css, is it possible?
You are welcome to buy the pro version and test it out. If you have any inquiries regarding the pro version, please visit https://poweredcache.com/support/ for assistance. Please note that providing support for the PRO version of the plugin on this platform is prohibited.
Thanks!
Hi @alriksson,
I made some adjustments in version 3.3.2 to support the custom wp-content structure. You may still need to tweak settings a little bit, but I think it’s better for a custom directory structure.
- The topic ‘404 MIME type issue’ is closed to new replies.