Enabling mod_rewrite on apache2

If you’re trying to enable mod_rewrite for apache2 on your ubuntu server (or any other distrib) and nothing works, this little writeup might save you a few hours of frustration !

To enable mod_rewrite on ubuntu server you should write the following command:

sudo a2enmod rewrite

Apparently, this isn’t enough to do the job, it actually enables the module and loads it, but it won’t show up in

sudo apache2ctl -l

after you’ve enabled mod_rewrite, it’s time for the fix to make it actually work !

head to /etc/apache2/sites-enabled/ and then edit the site you’re currently using mostly it’ll be the file: 000-default

When you open the file, you’ll notice it’ll probably look like this :

<VirtualHost *:80>
ServerAdmin admin@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride none
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride none
Order allow,deny
allow from all
</Directory>

You need to replace the occurrence of AllowOverride none to AllowOverride all

now the file should look like this :

<VirtualHost *:80>
ServerAdmin admin@localhost

DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>

After editing your file, you will need to restart your apache2 server to see the changes !
in your terminal, type:

sudo service apache2 restart

Now fire up your browser and check your working mod_rewrite !, happy development.

6 comments

  1. henree   •  

    thanks a lot 🙂

  2. Cheryl   •  

    I’m amazed, I must say. Rarely do I come across a blog that’s both educative and amusing,
    and without a doubt, you have hit the nail on the head. The problem is something that too few people
    are speaking intelligently about. I am very happy that I stumbled across this during my search for something relating to this.

  3. Mitchel   •  

    Hi there friends, its enormous article on the topic of cultureand entirely
    defined, keep it up all the time.

  4. Steve   •  

    I think that is one of the most important info for me. And i’m happy studying your article.
    But should statement on some general things, The web site taste is wonderful, the articles is in reality
    excellent : D. Excellent activity, cheers

Leave a Reply to Cheryl Cancel reply

Your email address will not be published. Required fields are marked *