I accidentally deleted my .htaccess file. Before that I could just delete everything in the var and pub/static folder (except the .htaccess file of course) and just reload the page to see my CSS / LESS changes. Without the .htaccess file the stylings completely disappear. Now I always have to run the bin/magento setup:static-content:deploy command in order to see my changes which takes for ever. Is there any way I can re-setup the .htaccess file?


3 Answers 3


You can download corresponding file from the official Magento 2 repository. That will solve your problem.

  • Does .htaccess needs be present in the directory if using nginx ?
    – Zoya
    Commented Dec 19, 2019 at 5:24
  • @Zoya you don’t need it without Apache Commented Dec 19, 2019 at 6:50

You can find the .htaccess file from below path :


Hope it may help you!

  1. You can find the .htaccess file at magento root/var
  2. There is one more .htaccess file you can find in root/ directory named as .htaccess.sample

Get the file into your root directory.

Remove the cache and try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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