How to enable Mod_Rewrite in Apache2 on Ubuntu
Was just doing this, and thought it’d be a nice guide to write up.
I’m assuming you already have Apache2 installed on your machine. If not, check how to install Apache 2 on Ubuntu.
Mod_rewrite is a module that allows runtime modification of the URL structure. Typically this is to allow .htaccess directives to implement friendly URLs. This is done frequently in WordPress and many other CMSes.
Link to the Module
Apache 2 on Ubuntu is a bit different than some servers, as Apache is usually controlled in the /etc/apache2 directory.
There will be 2 directories for enabling mods, they are /etc/apache2/mods-enabled and /etc/apache2/mods-available. Mods-enabled includes a list (hopefully links) of files that are enabled via the configuration file (if you look, there’s a command to load all modules in that directory). Mods-available, is all modules you can enable.
To create the link:
cd /etc/apache2/mods-enabled
ln -s ../mods-available/rewrite.load rewrite.load
That’s ready …
Allow Mod Rewrite
Once you have the module “Enabled” (not yet since we didn’t restart apache, but essentially enabled), you need to let your instance override.
If you go to your /etc/apache2/sites-available folder you can edit the configuration of your site, if not you can do default (this example assumes “default”):
vi default
You should see a line that lists your directory before (/home/web/public_html for example) and afterwards it will say “AllowOverride none“. You want to change this so:
[Move cursor to "none"]
[hit "i"]
[hit Del to remove "none"]
[type "all"]
[hit Escape]
:wq
That should change it (you can edit the file however you want, it’s an easy fix).
Restart Apache
Simply (at the command prompt):
service apache2 restart
Related Posts
10 Comments to How to enable Mod_Rewrite in Apache2 on Ubuntu
A typo in your instructions… You say to replace “Allow None” with “Allow None”, but I think you meant to say to replace with “Allow All”
Unfortunately, I can’t get rewrites working on my Ubuntu 12.04 laptop, even though I’ve followed these (and other, identical) instructions
June 12, 2012
Same here. I can’t get these instructions or others to work with Ubuntu 12.04. Everything seems to respond okay, but it doesn’t work.54
July 18, 2012
I can’t get it working too, but I found the cause:
Commands wrote here:
cd /etc/apache2/modes-enabled
ln-s ../mods-available/rewrite.load rewrite.load
Should be:
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/rewrite.load rewrite.load
Tip for future: DON’T copy&paste commands!
July 29, 2012
I am using Ubuntu 12.04 and this solution worked for me. Thanks!
Anyway, instead of creating symbolic link directly, we can also use this command in terminal:
sudo a2enmod rewrite
Thank you
August 3, 2012
Thanks for this post. It helped me when I was configuring my fresh installation of Concrete5.
September 2, 2012
Thanks a lot
One Correction.
Dude you wrote “modes-enabled” that is “mods-enabled”
September 2, 2012
Thanks for pointing that out — hard to keep track of mods and modes sometimes
September 9, 2012
Perfect – got me up and working thanks!
November 16, 2012
Thanks
November 20, 2012
Thanks!!!
Leave a comment
Please share, it makes me happy:
Subscribe to Email Alerts
Make a Donation
Popular Posts
Follow Me
Recent Posts
Archives
Tags
Blogroll
- 456 Berea St
- ActionScript 3 Design Patterns
- adactio – home of Jeremy Keith
- ajaxian
- Boxes and Arrows
- Chris Brogan
- CSS Globe
- InsideRIA
- Jarrod Michael Studios
- Johan Brook: Designer and Developer
- Mad Vertices
- NETTUTS
- Portsmouth Community Calendar
- Roomware Blog
- Signal vs. Noise
- Six Revisions
- Snook
- Style Grind
- Tiago’s Weblog
- Viget Extend
- Vitamin
- Whats the latest
- Woork
- zupko.info

March 28, 2012