mod_rewrite will not be isntalled by default when you install apache web server and php on Ubuntu. To use mod_rewrite on ubuntu you can use the the following command in the terminal
# a2enmod rewrite
Restart apache2 server
# /etc/init.d/apache2 restart
you can use the following sample .htaccess file
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>
The sample .htaccess file will redirect all traffic to an index.php file in the DocumentRoot unless the file exists. Let’s say you have the following directory structure and httpdocs is the DocumentRoot
httpdocs/ .htaccess index.php images/ image1.jpg image2.jpg js/ jquery.js css/ style.css
Any file that are in httpdocs will be given to the requester by the .htaccess file. Anything else that does not exist will be redirect to httpdocs/index.php