mod_rewrite
is a module for the Apache webserver
that allows apache to dynamically change the url of a site using php (or other scripting languages). It seems like a difficult/confusing task at first, but it actually only takes 2 steps in Ubuntu
. I’m using Feisty Fawn, 7.04, but this should work well for Edgy and Dapper without any issues. Any code snippets should be typed into a terminal. “sudo” commands require a password, that’s a given.
- Enable mod_rewrite in Apache
sudo a2enmod rewrite
- Edit the configuration file.
sudo gedit /etc/apache2/sites-available/default- line 12 says “AllowOverride none” ;
- change it to “AllowOverride all”
- save and close
- Okay… one last step — you have to manually restart Apache (or restart your computer!)
sudo apache2 -k restart
All done! now Apache and php can create URL’s on the fly - pretty neato!

12 responses so far ↓
1 Lloyd Budd // Jun 19, 2007 at 3:37 pm
Thank you, this solved my problem.
2 Midlain // Jul 15, 2007 at 8:46 am
Very helpful. Thanks & cheers!
3 Del // Jul 19, 2007 at 9:58 am
Thank you. I have been looking for this solution for a while now. Thank you.
4 laizer // Aug 22, 2007 at 5:05 am
Awesome. Huge help.
5 Jim // Sep 2, 2007 at 3:46 pm
I have been beating my head against a wall figuring out why PHP5 wasn’t working, this fixed it in 5 minutes. Thanks for the help.
6 Maƫl // Sep 28, 2007 at 11:54 pm
Wow. Thanks a lot.

All the help I could gather up to now was only dealing with apache2.conf ;
editing ‘default’ really was the point.
You just saved my night !
7 adler medrado // Oct 12, 2007 at 5:40 pm
Thank you. It was very useful for me.
regards,
8 chris // Dec 10, 2007 at 8:23 pm
This was very helpful. Thanks.
9 Student Affairs - Austin » mod_rewrite for Apache2 in Ubuntu Feisty Fawn 7.04 // Jan 10, 2008 at 8:34 am
[...] This article is originally from Huanix tutorial site [...]
10 Brian Hart // Mar 18, 2008 at 1:04 pm
Very helpful, thanks for the succinct tip.
11 colombiano // May 25, 2008 at 2:57 pm
gracias, it worked for me
12 sagittariuspl // Jun 20, 2008 at 8:36 am
if you want restart apache use sudo /etc/init.d/apache2 restart
Leave a Comment