Hi,
I’ve setup a droplet with Ubuntu LAMP on 14.04, enabled mod_rewrite using sudo a2enmod rewrite and confirmed this with phpinfo().
I’ve also setup a vhost with using the following config:
<VirtualHost *:80>
ServerAdmin foo@foo.co.uk
ServerName foo.com
ServerAlias dev.foo.com
DocumentRoot /var/www/dev_foo/public_html/application/
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
My 000-default.conf file is this:
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
But I can’t get it to work, any tips?
Thanks
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.
If you’re having problems configuring your server to enable
mod_rewrite
, you might want to try a software stack such as the one used by ServerPilot that enablesmod_rewrite
by default for your sites.Thanks for the speedy response, sadly I’ve tried that and it doesn’t work :(
In order for directives in an .htaccess file to be used you need AllowOverride All set for the vhost responding to the request. You will want to copy over the relevant section from the default to your new vhost and restart apache:
After that the .htaccess directives should work properly.