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.
Execute the following command (as root) in a terminal:
Mod_rewrite should then be installed on your Ubuntu Linux server in a couple of seconds.
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:
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.