Apache mod_rewrite in Ubuntu/Mint

There are many tutorials for setting up mod_rewrite for Apache, but most of them are missing one critical step. To be honest, I’m writing this as much for myself as I am for anyone else. I’m tired of looking around for the missing step every time I setup mod_rewrite on a new machine. So here it is. First, turn on the rewrite module using this command:

sudo a2enmod rewrite

Next, find the following file and open it as an administrator:

/etc/apache2/apache2.conf

In the /var/www/ section, change:

AllowOverride None

To:

AllowOverride All

Finally, restart Apache with the following command:

sudo service apache2 restart

That’s it!

Disclaimer: I tried a bunch of different methods before finally getting mod_rewrite to work properly. I believe these are the only steps that actually made a difference, but there is a slight possibility that something else I did had some effect as well. If these steps don’t work for you, feel free to comment and I’ll see what I can do to help.

Posted in

9 thoughts on “Apache mod_rewrite in Ubuntu/Mint”

    1. Thanks man! I actually just installed Mint 18 today and came back to this post to get mod_rewrite set up again. I’m glad you found it useful as well!

  1. Thanks this was a great help.

    However I also just found that there is an error in many of the examples that make use of editing the file 000-default.conf rather than apache2.conf

    Many examples online leave off the trailing slash in /var/www/html/ and therefore don’t work.

    Adding the following to 000-default.conf will work.

    Options Indexes FollowSymLinks
    AllowOverride All

    Hope this helps some people.

    1. Thanks Andy!

      I think that 000-default.conf vs. apache2.conf might depend on which Linux distribution you’re using. I don’t remember exactly though, because I’ve been using Mint for so long now. Thanks for the additional info!

Leave a Comment

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