How do I solve incorrect MIME types being served on appended URLs?

I'm running a basic website used to practice php and some other things both locally with WAMP and on a hosted server with LAMP, both running with their default setups. I've been searching for hours to find a solution to this issue, and come across many topics with suggestions but these all seem to be related to files not being served properly at all. In my case, all the file types (css, js, images) are served as they should as long as I don't append the URL with anything.

For example; if I type 'local/index.php' as the URL the page loads as it should, with css, scripts and images being served with the right file type. Correct GET responds

However, if I append the URL and go to 'local/index.php/' the page loads but all files in the GET request are served with type html (except for the google fonts stylesheet): Screenshot with incorrect file types.

Both my local environment and online version have this issue.

I've tried adding an .htaccess file like some threads suggested, which wasn't there by default. I've checked the mime types file, which seemed to have the settings that people suggested to check for. I've tried adding these lines to the httpd.conf:

AddType text/css .css
AddType text/javascript .js

I'm getting this on all browsers I've tested (chrome, firefox, IE), and also tested on my mobile phone in case it was a client sided issue, but all with the same result.

If anyone could tell me what's going wrong I would greatly appreciate it! If you need more (specific) info let me know and I'll do my best to provide it.

Thanks in advance!

EDIT: All right, I'm feeling rather stupid now. I was referring to file locations with "./dir/file" because before I had read that "./" refers to the root directory. So my href on my style.css file was "./css/style.css", and never suspected that to be wrong because all my files were loading properly until the URL got extended. Simply changing the href to "../css/style.css" (and replacing "./" with "../" for all other files) fixed my issue of getting the wrong content-type.

链接地址: http://www.djcxy.com/p/41302.html

上一篇: 数据库字段的标准长度列表

下一篇: 如何解决在附加URL上提供的不正确的MIME类型?