Enable mod_rewrite on Ubuntu

It is very easy to enable mod_rewrite in Ubuntu as you will see in the tutorial below. The rewrite module (mod_rewrite) is used by the Apache web server to rewrite requests on the fly. By rewriting requests, we mean that the URL that is sent by the user is changed to something different internally before it is passed to the script which is processing the request.

Newer servers which run Ubuntu 10, Ubuntu 11 or Ubuntu 12 with Apache2 installed, can have mod_rewrite installed with a single command.

Enabling mod_rewrite on Ubuntu

Execute the following command (as root) in a terminal:

a2enmod rewrite

Mod_rewrite should then be installed on your Ubuntu Linux server in a couple of seconds.

What is mod_rewrite good for?

Mod_rewrite is used mainly to remove query strings from URLs. Search engines don't like URLs with query parameters in them, and so we usually use mod_rewrite to "clean up" those URLS.

For example we could clean up:

http://www.111movies4u.com/index.php?year=2012&type=action&title=Deathbot

To get:

http://www.111movies4u.com/2012/action/Deathbot

The latter is much easier for the search engine to process and for the user to remember. So by setting up URL rewriting properly, we can have the visitor going to a clean URL and have it transformed to the mess that our server expects behind the scenes. Rewriting URLs is beyond the scope of this tutorial and is an entire topic to itself.

We hope this tutorial on enabling mod_rewrite in Ubuntu was helpful.

Thank Tutorial Arena for This Tutorial.
Show your appreciation with a +1...