Enabling Mod Rewrite on Ubuntu
by Jarrod posted 1 year ago
If you've already searched the Internet you'll like have quickly come across loads of posts about how to enable mod_rewrite on Ubuntu. Still doesn't work? I'll tell you why.
To begin, let's make sure you have actually enabled mod_rewrite. At your terminal prompt, enter the following:
$ sudo a2enmod rewrite
Easy. Did it work? if so great! If not, try these next couple of steps. Again in the terminal, open up the following file with:
$ sudo gedit /etc/apache2/sites-available/default
And now change the AllowOverride value to "All". I have included what the file should now look like for a default installation.
Restart Apache and you're done:
$ sudo service apache2 restart
Below is a sample file with the aforementioned changes.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All <- HERE
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All <- HERE
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
Mr. Oberto, you just saved my day! Thank you so much.
Thanks mate, worked very nicely.
I get /bin/sh: $: command not found what to do ?
Thanx
Thanks. "AllowOverride All" works.
You are Mr. bad-ass! I've been to over 10 sites, but none of them helped me, till I read this.
Thanks a lot Mr Jarrod .. This article did it finally for me :) :)
Thanks! While loads of others didn't , your post really helped~!
Everything was working fine until I upgraded Ubuntu, then suddenly for no reason my rewrite rules stopped working! I guess some Apache config file must have been overwritten; thanks for this, it was just what I needed!
This post may be more than a year old but you just helped me solve a 2 1/2 yr old problem. Thanks for the tut it was spot on.
Worked like a charm, thanks!
Worked for me also! I am saving this link in so many places. Thanks
These instructions worked perfectly! Exactly what we needed to end the frustration with getting mod_rewrite to work.
Great!!!!!!! It works! Fantastic! Thank you!
Thanks a lot! That helps :-)
Worked perfectly Thanks!
This saved my day.