I set up Magento 2 localhost migrated from the server.

but when load frontend showing like this

enter image description here

Pub/media CSS was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff in Magento 2

how I can fix this

Magento ver 2.2.6

ubuntu 18.04



Make sure you have .htaccess in pub/static. If you don't have file take a file from a fresh setup.

Then do static content deploy and clear cache.

If It's not working make sure you have enabled mod_rewrite in ubuntu

  • mine backend is working fine without any problem – prabhakaran7 Jul 23 '19 at 4:23
  1. Remove all files from var/ folder.
  2. Check for .htaccess in pub/static. If not exists, take a file from a fresh setup.
  3. Run the following commands

    php bin/magento setup:static-content:deploy -f
    php bin/magento indexer:reindex
    php bin/magento cache:clean
  • already there and i cleared cache – prabhakaran7 Jul 23 '19 at 4:22
  • but magento backend is working fine – prabhakaran7 Jul 23 '19 at 4:23
  • then flush cache and clear browser history then try in incognito mode – Teja Bhagavan Kollepara Jul 23 '19 at 4:23
  • tried not working – prabhakaran7 Jul 23 '19 at 5:50

I had the same issue. The reason was that we added a css file which didn't exist when enabling merging css. Please check your custom js or third party js. We can also check the log.

For example, file doesn't exist.

<css src="Vendor_Module::yourcustom.css"/>
  • i will check ..... – prabhakaran7 Jul 23 '19 at 12:08
  • @prabhakaran7 did your issue resolve? – Khoa TruongDinh Jul 26 '19 at 3:48
  • still i'm not yet checked... – prabhakaran7 Jul 26 '19 at 4:37
  • Is there any method to find error like this? I got this error only in js file – himansu Dec 7 '20 at 16:20

make sure .htaccess exist in pub/static


enter image description here Same problem I am getting on my localhost so for this I have tried below methods: * replace .htaccess file in pub/static folder (no luck) * after lot search I run this commands and successfully deployed

 sudo chmod -R 777 pub/ var/ app/
 sudo php bin/magento setup:upgrade
 sudo php bin/magento deploy:mode:set production
sudo chmod -R 777 pub/ var/ app/

After these commands all errors from console gone enter image description here

  • superb let me try – prabhakaran7 Nov 23 '19 at 13:50
  • Deploy mode in production works well... If this perfect then upvote my ans – Rohit Kaushik Nov 24 '19 at 14:40
  • Already updated .htaccess from default Magento 2.2.9 and run below command but got error on js files only. – himansu Dec 7 '20 at 16:22
  • can you try to change deploy mode again and run same commands, this is only cause of mode changes, also check if you are using multiple language then deploy using 'php -d -f bin/magento setup:static-content:deploy -f en_US th_TH fr_FR' – Rohit Kaushik Dec 9 '20 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.