To enable rewrite, run below command
a2enmod rewrite

To rewrite your url, add below lines between <VirtualHost></VirtualHost> tag
RewriteEngine on
RewriteCond %{http_host} ^yourdomain.com [nc]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]

To rewrite your url, open your .htaccess and add below lines
Options +FollowSymLinks
RewriteEngine on
RewriteRule hikaye/(.*)/(.*)/ index.php?i=$1&title=$2
RewriteRule hikaye/(.*)/(.*) index.php?i=$1&title=$2
RewriteRule haber/(.*)/(.*)/ news.php?news_id=$1&news_title=$2
RewriteRule haber/(.*)/(.*) news.php?news_id=$1&news_title=$2

To redirect yourdomain.com to www.yourdomain.com (for Google Analytics), add below lines to .htaccess
RewriteEngine on
RewriteCond %{http_host} ^yourdomain.com [nc]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [r=301,nc]

The following example will rewrite the test.php to test.html i.e when a URL like http://localhost/test.htm is called in address bar it calls the file test.php. As you can see the regular expression in first part of the RewriteRule command and $1 represents the first regular expression of the part of the RewriteRule and [nc] means not case sensitive.



Options +FollowSymlinks
RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [nc]



The following example will rewrite the product.php?id=5 to porduct-5.html i.e when a URL like http://localhost/product-5.html calls product.php?id=5 automatically.





Options +FollowSymlinks
RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ products.php?id=$1