How can I enable htacess Centos apache?

I can’t run .htaccess files on my website. How can I enable it? I am using Centos 7 with apache.

I tried editing /etc/httpd/conf/httpd.conf and added

<VirtualHost *:80> ServerName

Disable .htaccess for /var/www directory for security

<Directory “/var/www”> Allowoverride none </Directory>

Enable .htaccess for /var/www/html directory and its subdirectories

<Directory “/var/www/html”> Allowoverride all </Directory> </VirtualHost>

But it doesn’t work…

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi @dtorgul,

Don’t worry my dude, Use the following configuration in your Apache Virtual host configuration file.

<VirtualHost *:80>
  # Admin email, Server Name (domain name), and any aliases

  # Index file and Document Root (where the public files are located)
  DirectoryIndex index.html index.php
  DocumentRoot /var/www/html/
  <Directory /var/www/html/>
      Options Indexes FollowSymLinks
      AllowOverride All
      Require all granted
  # Log file locations
  LogLevel warn
  ErrorLog  /var/www/html/
  CustomLog /var/www/html/ combined

Please specify the exact location of website root directory (/var/www/html/ in the configuration.

Okay I find it… Open /etc/httpd/conf/httpd.conf and search this: AllowOverride controls what And edit AllowOverride to All