Home >Web Front-end >CSS Tutorial >Why Aren\'t My CSS Files Loading After Switching from Apache to Nginx?
Nginx: CSS Files Not Loading
When migrating from Apache2 to Nginx, a user encountered an issue where CSS files were not loading properly. The error message in the browser console indicated a mismatch in MIME types.
Despite having the correct MIME type (text/css) specified in /etc/nginx/mime.types, the issue persisted. The user ensured that the mime.types file was included under the http section of the nginx.conf configuration file:
http { include /etc/nginx/mime.types; ... }
However, the problem was resolved upon moving the include statement to a location block:
server { ... location / { include /etc/nginx/mime.types; ... } ... }
This modification ensures that the MIME types are correctly interpreted for the specific location, resolving the issue of CSS files not loading.
The above is the detailed content of Why Aren\'t My CSS Files Loading After Switching from Apache to Nginx?. For more information, please follow other related articles on the PHP Chinese website!