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:


Starting with Ubuntu version 13.10 (I think), this file has been removed and you’ll want to edit the following file instead:


In the /var/www/ section, change:

AllowOverride None


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 September 13, 2012 by Alex Mansfield

9 responses to “Apache mod_rewrite in Ubuntu/Mint”

  1. Jeff says:

    I’ve been trying for a while to WordPress running on my laptop. This worked. Thanks!

  2. David says:

    This helped me as well

  3. Navas says:

    Perfect solution

  4. Mohsen says:

    Ah Thank You very much
    That helped me a lot

  5. yakuter says:

    Your are great men, this solved my issue 😉

    • alexmansfield says:

      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!

  6. Andy says:

    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.

    • alexmansfield says:

      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 Reply

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

  • PublishedSeptember 13, 2012
  • Posted InLinux