Apache – mod_rewrite rules

Examples to configure rewrite rules in .htaccess file:
http://yourdomain.com/test

RewriteEngine On
RewriteRule ^test/?$ /testpage.php [L,NC]


Rewrite localization url with $_GET[‘lang’] variable
http://yourdomain.com/english

RewriteEngine On
RewriteRule ^(.*)/$ /$1 [R=permanent]
RewriteRule ^([a-z]{2})$ /index.php?lang=$1


Redirect 301

http://www.yourdomain.com/ to http://yourdomain.com/

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Apache – mod_rewrite rules