最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to fix mime-type and (after disabling nosniff) 404 errors for css and js files in staging site

programmeradmin1浏览0评论

I set up a staging site from the live site with my hosting, A2 Hosting. The pages are all messed up, and in the browser console, I could see lots of mime type errors (photo for examples). The errors come from CSS and JS files from all the plugins and theme.

I talked to hosting support, and they edited the .htaccess file to disable nosniff, so the browser can see what they really are. But now they are generating 404 Not Found errors in the Network tab of the browser developer tools. But if I copy one of the URLs from the error and put it in another browser tab, it comes right up, no problem.

This makes no sense to me, and I would appreciate a pointer how to fix it.

I set up a staging site from the live site with my hosting, A2 Hosting. The pages are all messed up, and in the browser console, I could see lots of mime type errors (photo for examples). The errors come from CSS and JS files from all the plugins and theme.

I talked to hosting support, and they edited the .htaccess file to disable nosniff, so the browser can see what they really are. But now they are generating 404 Not Found errors in the Network tab of the browser developer tools. But if I copy one of the URLs from the error and put it in another browser tab, it comes right up, no problem.

This makes no sense to me, and I would appreciate a pointer how to fix it.

Share Improve this question asked Oct 7, 2020 at 20:17 Jim WorrallJim Worrall 1777 bronze badges 2
  • Looks like your hosting provider does not configure MIME types for Apache. Check this article, you need at least AddType text/css .css and AddType application/javascript .js. – Ivan Shatsky Commented Oct 7, 2020 at 21:47
  • Thank you Ivan. That seemed promising, but still getting the mime type mismatch errors or 404 errors, depending on whether the line in .htaccess "Header always unset X-Content-Type-Options" is set. No caching plugins, cleared browser cache. – Jim Worrall Commented Oct 7, 2020 at 22:18
Add a comment  | 

1 Answer 1

Reset to default 0

I found there were two problems causing this:

  1. There is some kind of server caching I apparently don't manage. I cleared that by adding a query to the URL (like staging.site/?a=b) and some things started being served, but many were still giving 404s.

  2. There was a rewrite rule in .htaccess designed to prevent hotlinking things in wp-content, allowing google and my site only. That was not updated to the staging URL during creation of the staging. So the staging site was blocking itself!

Sorry, I know this kind of thing would be impossible for anyone to solve unless you had full access to the site and tons of time to devote to it. I appreciate people looking.

发布评论

评论列表(0)

  1. 暂无评论