Question
How To Set Up Mod_Rewrite?
Hi
I’ve followed the How To Set Up Mod_Rewrite guide.
- I’ve enabled mod_rewite
- Used
sudo a2enmod rewrite
to test it’s been enabled. Terminal outputs: Module rewrite already enabled - All my website files are in
/var/www/html
The guide says,
To allow the .htaccess file to override standard website configs, start by opening up the configuration file.
I ran this command sudo nano /etc/apache2/sites-available/default
and the file was empty
So I copied and pasted the example
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
and ran sudo service apache2 restart
to restart the apache server.
I’m using a .htaccess
file I’ve used for other websites, so unless there’s anything specific I need to include for Digital Ocean, it should work…
The .htaccess
is inside the html
folder located at /var/www/html
I’ve cleared the cache, restarted the browser and the mod_rewrite
isn’t working?
I then noticed the example code above was pointing at /var/www/
so I changed it to /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Cleared the cache, restarted the browser and the mod_rewrite
still isn’t working?
Any ideas?
I’m very impressed with the speed of Digital Ocean Hosting! Would like to get this fixed :)
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.
×