This will be a quick lesson with a script we use all the time.
Most applications that use our databases use a simple query format: query.php?keywords=something here
This simple query is presented in the mod rewrite code as query.php?keywords=$1
So to begin, be sure to always add these two lines in your .htaccess file:
Options +FollowSymLinks
RewriteEngine On
Your next line will take the URL
[yourdomain.com/mod rewrite.htm]
and rewrites it on the Server Side to
[yourdomain.com/query.php?keywords=mod rewrite]
The entire code, which is placed into your .htaccess file is:
Options +FollowSymLinks
RewriteEngine On
RewriteRule (.*).htm$ query.php?keywords=$1
There are many variables available in Mod Rewrite, but this should give you a basic format to begin with.
By having this code in your .htaccess file you can now use SE Friendly URLs. So `yourdomain.com/roses.htm` and `yourdomain.com/furniture polish.htm` will be converted on your server and deliver content from your database about `roses` and `furniture polish`.
And to give you something a little more advanced, we will leave you with the following mod rewrite code. Understanding the above information should give you a good base of understanding from which to understand the following:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2+$3+$4+$5Â
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2+$3+$4
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2+$3
RewriteRule ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1+$2Â
RewriteRule ([a zA Z?0 9]+).htm$ search.shtml?keywords=$1
RewriteRule ([a zA Z]+)/$ search.shtml?keywords=$1
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$2+$3+$4+$5Â
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+) ([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$2+$3+$4
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+) ([a zA Z?0 9]+).htm$ search.shtml?keywords=$2+$3
RewriteRule ([a zA Z?0 9]+)/([a zA Z?0 9]+).htm$ search.shtml?keywords=$2