404 error

Nothing to see here

Honest.
If you think something is broken, report a problem, in triplicate.

Apache2 – Directory Browsing on by default! RedirectMatch 404, and git exclude

I had no idea this was the case – Apache2 Directory Browsing on by default. Only found out when I added a .git initialisation to my “xarta” folder as my JavaScript was outgrowing WordPress’s Header/Footer plugin and I wanted to use Visual Studio Code’s intellisense – in particular with the three.js library. I checked to make sure nothing would be served from it and then realised … oops!

sudo gedit /etc/apache2/apache2.conf   
/etc/apache2/apache2.conf
  <Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>

Changing to:

/etc/apache2/apache2.conf
  <Directory /var/www/html>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
  </Directory>
sudo service apache2 restart   

Next, I wanted to prevent some directories from being served. E.g. any git directories, and a directory where I could put stuff that PHP could find … e.g. my contact details file, but what I wouldn’t want to serve directly or include in files I might put on GitHub.

.htaccess [Read-Only] (/var/www/html) -gedit
  <IfModule mod_rewrite.c>
    RedirectMatch 404 /\.git
    RedirectMatch 404 /xprotected
    RedirectMatch 404 /git.token
  </IfModule>

And finally, some folders – like the “xprotected” directory, are to be ignored by Git …/.git/info/exclude:

exclude [Read-Only] (/var/www/html/xarta/.git/info) -gedit
   /xprotected/*