TLDR; I had my code in a sub directory that was unable to find my stylesheet
Hi Windows Users on Xampp/mampp/lampp in 2019. I have a fix that worked for me that will work for you and it's to do with our environment setup. This was from a Laracasts Tutorial. PHP Practitioner
This was a breaking point for me and i made it over so you can too!
This is regarding both the errors where you copied jeffs code and still get a 404 OR you receive the error "Resource interpreted as Stylesheet but transferred with MIME type text/html".
First off, your .htaccess file should look like this:
RewriteEngine On
AddType text/css .css
AddType text/javascript .js
RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteRule ^.*$ index.php [END]
Secondly all of your project files MUST 1000% go to your htdocs folder located at: C:\xampp\htdocs
Finally, if you are getting any more errors after this please email me at [email protected] and i will personally help you
Answer from Roman Ozerski on Stack Overflowexternal css linked with html not working with apache server
CSS not linking with Apache 2 Server - Raspberry Pi Forums
Updated to Apache 2.4 and now my style sheets do not load - Server Config - SitePoint Forums | Web Development & Design Community
apache - Enable PHP to read .css and .js files while keeping their original Content-Type - Stack Overflow
Enable mod_mime and add the following lines in your httpd.conf (or a .htaccess):
AddType text/css .css
AddType text/javascript .js
When I load your website and look into the console, it displays the following error
[16:37:08.652] The stylesheet http://shurl.be/layout/stylesheets/css/test.css was not loaded because its MIME type, "text/plain", is not "text/css". @ http://shurl.be/
It seems you're missing an appropriate mime type. Although, the default configuration of debian should do this already.
I think I see the problem. Your SetHandler is applying to every possible URL in the virtual host, without regard for whether it is a PHP file or not. Thus everything gets passed to PHP, even if it is a static file. And because PHP's interpreting the static file as PHP, you get the results you got.
You should instead send only requests for PHP files to the handler, by selecting them by filename:
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9072"
</FilesMatch>
You can then remove the unnecessary redundant <Files> bits that you had added.
The 403 error usually comes from a permission error. It could either be at the directory or the files level.
In your case, from what I can see (only the file and the apache doc root directory permissions), permissions seems fine.
Could you share with us the parents directories permissions? (it could be the /var/www/dev/ that have too restrictive permissions)
If the permissions aren't allowing "other", 0755 should do it...
chmod 0755 /var/www/dev
Also, /var/www/dev should belong to "dev-admin". If that isn't the case, I would suggest to change the ownership of it:
chown dev-admin: /var/www/dev
And @Michael Hampton is right. None of your changes were required (on a default CentOS 7 Apache configuration).
Ohh! Just to make sure that we are covering all the bases... Does dev-admin is the Apache user?
If not, you may either change it within the main Apache configuration or by changing the dev directory (recursive) with the proper user.
I didn't try that, but from the docs it looks possible:
<Files *.css>
php_value default_mimetype "text/css"
</Files>
<Files *.js>
php_value default_mimetype "application/x-javascript"
</Files>
# ... and so on for other types
If I absolutely had to do that, I would have made a special view for CSS and JavaScript files. For example, I would tell my application to handle all requests to, say, /pseudostatic/css/somefilename.js by a certain controller, which would take a template based on the name of a requested file, prepend all the needed global variables to it and serve it with a needed header.
And I would use caching based on the file's timestamp.
But I think this is realy an unnecessary pain. I bet you can find a way around, like keeping most of your CSS and Javascript in static files and loading only a tiny bit of server-side generated scripts and styles directly inside the requested page. This way you will save your server a lot of processing time.
Not only you need to set the correct permissions for the folder, but also for the file you are talking about. Please issue:
chmod 0644 /path/to/blog/js/bootstrap.js
Or any other permissions mode that will let Apache access the file.
That error indicates that the problem is a javascript file, not a css file.
Also, it's most likely that it is your Apache configuration and not your file permissions that are causing Apache to deny access. Apache, out of the box, in most Linux distributions, is configured to restrict access to the file system except where the configuration indicates that it is permitted.
Finally, setting permissions to 777 is never the answer. Please change them back to something reasonable.