Mod_rewrite is a very important library to enable search engine friendly URLs in apache web server. Almost every framework takes advantage of this mod to make user experience more colorful while browsing a page. If you are not sure what is a search engine friendly URL, have a look at the following examples
1. http://your_domain/yourpage.php?param1=list¶m2=12
2. http://youor_domain/list/12
In the examples above, second one is more readable than the first one. In fact search engines don’t index pages from a dynamic URL(i.e first example) which ultimately lowers your page rank. Thats why search engine friendly URLs are very important to increase your ranking in search engines.
For web application developers, here is a “how to” to enable mod_rewrite in ubuntu 7.10 (I assume you have apache2 installed in your machine, :D)
Step 1:
sudo cp /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/
This will copy the available mod_rewrite loader to the appropriate directory. Apache will load all mods by reading these loader present in the “mods-enabled” directory.
Step 2:
If you have one virtual hosting (that means your localhost actually points to /var/www) then change the file “/etc/apache2/sites-enabled/000-default” and replace the following line
AllowOverride None
with
AllowOverride all
Step 3:
Restart your apache server using the following command
sudo /etc/init.d/apache2 restart
Now you need to check out if the mod_rewrite is working properly. Place the following code in a file named “.htaccess” in your localhost (/var/www) and point your browser to “http://localhost”. If you don’t see any 500 internal error, consider its working :)
RewriteEngine On
Easy, huh?





5 Responses to “Setting up mod_rewrite in Ubuntu 7.10 Gutsy Gibon”
August 14, 2008
TheAnomalyFWIW, this saved me like you can’t believe. I just spent the past two hours trying to figure this out–digging through all kinds of complicated junk, and FINALLY, I got here. Your commands worked perfectly, and I’m a happy man.
Thank you very much.
September 16, 2008
jacintothank you. that helped me a lot! Also works with 8.04.
September 22, 2008
SauliusThanks, this info was very usefull for me :)
March 5, 2009
bahodirThank you man!
Works great with 8.10 too.
Stumbled. Thumbs UP.
September 20, 2009
MohammadThank You man, thank you. It was hours that i was engaging without coming to any result