Enabling Mod Rewrite on Ubuntu
by Jarrod posted 2 years agoIf 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.
Thanks! Server works great!
Thank you, this solved a problem I was suffering with Worpess' permalinks.
God bless you! I wish I had located your site yesterday when I started facing the problem. Now it is fixed.
You saved my whole day. Great work posting the information !
Thank you! This helped with my wordpress migration, but I had to leave only these entries because apache wouldnt start otherwise: ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks AllowOverride All <- HERE Options Indexes FollowSymLinks MultiViews AllowOverride All <- HERE Order allow,deny allow from all
Hi, Thanks for the solution!
Hey man... thanks for this article. As many have said... "you saved my day"
You saved my day bro!!!! Thank you!!!!!!
'sudo a2enmod rewrite' and now im happy ;)
Thanks! Server works great!
Thank you so much for this helpful article.
Very helpful, thx a lot :)
Thanks!
Hi, What about for the new 13.10 newer apache configuration: 000-default.conf this file looks completely different?
Hi, What about for the new 13.10 newer apache configuration: 000-default.conf this file looks completely different?
Spot on. Have been battling with the apache configs for ages and found the rewrite modules was not on, a2enmod rewrite sorted it. Cheers
thanks it has helped me. is there any security issue in writing AllowOverride All
Exceptional explanation with no BS, thank you!
Straight-forward solution. Great!
Thanks... work for me i edit AllowOverride none to AllowOverride All
Thanks, this stumped me for about an hour...
thanks
Thanks dude! This really helped me!
Thanks a lot !! = )