My problem is that my .htaccess
file on my local server is not being read. The settings in the VirtualHost
file seem to always take precedence.
I have tried the following:
mod_rewrite
AllowOverride
to All
but this causes a HTTP Error 500 Internal server error
. I have tried it with various options but it always causes a 500 error.I am using a VirtualHost file on Ubuntu which looks like the following:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /web/website
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /web/website>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
In my .htaccess
file under /web/website
I have the following rules (which are not being read):
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{HTTP_USER_AGENT} ^facebookexternalhit
RewriteRule ^(.*)$ ogtags.php?$1 [L,QSA]
ErrorDocument 404 /404
ErrorDocument 401 /401
One thing I tried which did work was appending these rules directly into the VirtualHost file, but I would like my .htaccess
file to work! Is that such a big ask? :(
Edit: So I looked in my apache error.log
and it says Invalid command 'Action', perhaps misspelled or defined by a module not included in the server configuration
referring to my .htaccess
file. There doesn't seem to be a module called Action which I can enable. Any ideas?
Edit 2: I noticed that my httpd.conf
file is blank. Should this matter since I am using VirtualHost
files?
After looking at my apache error.log
I realised I just had to enable the Apache actions
module:
sudo a2enmod actions
And no more 500 Internal Server Errors!
Hope this helps somebody down the line :)