///Setting up mod_rewrite in Ubuntu 7.10 Gutsy Gibon

Setting up mod_rewrite in Ubuntu 7.10 Gutsy Gibon

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&param2=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


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?

2008-02-14T11:29:58+00:00 February 14th, 2008|General|5 Comments

About the Author:


  1. TheAnomaly August 14, 2008 at 6:23 PM

    FWIW, 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.

  2. jacinto September 16, 2008 at 2:45 AM

    thank you. that helped me a lot! Also works with 8.04.

  3. Saulius September 22, 2008 at 8:06 AM

    Thanks, this info was very usefull for me :)

  4. bahodir March 5, 2009 at 1:22 PM

    Thank you man!
    Works great with 8.10 too.
    Stumbled. Thumbs UP.

  5. Mohammad September 20, 2009 at 8:25 AM

    Thank You man, thank you. It was hours that i was engaging without coming to any result

Leave A Comment