4

guys the website is working fine, just the file .htaccess that doesn't work, i googled a lot, already enabled a2enmod rewrite and tried a lot of stuff but it didn't work.

obs: i'm using the website example.com as example

this how my /etc/apache2/sites-available/000-default.conf is:

<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

and this how my /etc/apache2/apache2.conf is:

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all denied
</Directory>

<Directory /usr/share> AllowOverride None Require all granted </Directory>

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>

this is how my .htaccess is:

#DISALOW DIRECTORY LISTING
Options -Indexes

ErrorDocument 400 /.error.php ErrorDocument 401 /.error.php ErrorDocument 403 /403.php ErrorDocument 404 /404.php ErrorDocument 405 /.error.php ErrorDocument 408 /.error.php ErrorDocument 414 /.error.php ErrorDocument 500 /500.php ErrorDocument 502 /.error.php ErrorDocument 504 /.error.php

but it's not disallowing directory listing, and not showing the content in 404.php when page is not found.

1 Answers1

7

The current default setup of the AllowOverride directive causes your problem. If you want to allow override of everything possible by a .htaccess file for certain virtual host, you need to change its configuration in a way as this:

cat /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com

DocumentRoot &quot;/var/www/example.com/public_html&quot;

&lt;Directory &quot;/var/www/example.com/public_html&quot;&gt;
    AllowOverride All
&lt;/Directory&gt;

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Don't forget to reload or restart Apache after change of the .conf files.

pa4080
  • 30,621