Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Your Email:
Webmaster Blog

Setting up mod_rewrite in Ubuntu 7.10 Gutsy Gibon

by Hasin Hayder


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

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?




Related Posts
» Two Giant Linux distribution to release new versions for the desktop users
» Debugging CakePHP applications in Zend Studio for Eclipse
» Learn regular expressions in PHP
» Getting Dell BCM4328 Wifi Card Working on Ubuntu 7.10
» Quick Photoshop Lighting Tips for Photographers
 


This post has 3 Responses so far.
  1. TheAnomaly Says:
    August 14th, 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 Says:
    September 16th, 2008 at 2:45 am

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

  3. Saulius Says:
    September 22nd, 2008 at 8:06 am

    Thanks, this info was very usefull for me :)

Leave a Reply

Ask A Question
characters left.