Creating a static link like
CODE
<a href="http://www.NewDomainName.com">My Home Page </a>
is still the best options as search engine bots can quickly pick-up such links. And you will definitely have a better chance of getting pages from your website indexed in major search engines.But many of us are gradually moving from the days of static HTML pages to the dynamic pages and we have started using link like:
<a href="http://www.yourdomainname.com?action=search&category=jewelry">Click here to search for Jewelry </a>
Drawbacks of using dynamic pages:
Using dynamic pages, instead of age-old static HTML one, may give the impression to the search engine that the same page is being re-loaded. This fact has been mentioned in the Google's guide for webmasters.
Here is an abstrat of what Google says about it:
QUOTE
....... our crawlers may suspect that a URL with many dynamic parameters might be the same page as another URL with different parameters. For that reason, we recommend using fewer parameters if possible. Typically, URLs with 1-2 parameters are more easily crawlable than those with many parameters. Also, you can help us find your dynamic URLs by submitting them to Google Sitemaps.
For more details in this regard, please visit Google.com
Also it becomes difficult for the visitors of your website to read and type url containing too many partameters like
http://www.yourdomainname.com?action=search&category=jewelry etc. etc.
So we may employ a technique to chage the dynamically created links to look like a static one.
So a link like this:
CODE
http://www.yourdomainname.com?action = search&category=jewelry
will look like
CODE
http://www.yourdomainname.com/search/jewelry.htm
How is it accomplished? This is what mod_rewrite does for you.
Create a file named : .htaccess ( no file name please) and upload it in the root directory of your webserver.
The file will contain the moe_rewrite instructions for your webserver.
Here is the General Format of a typical .htaccess file.
RewriteEngine On
RewriteRule Pattern Substitution OptionalFlags
That file will contain the RewriteRules for your website. And whenever your webserver gets a request, it will check for the RewriteRules as written in your .htaccess file and then deliver the webpages as per instructions of the .htaccess file.
The structure of a RewriteRule
RewriteRule Pattern Substitution [OptionalFlags]
Let us explain what all these mean.
RewriteRule
This command tells the server that now we are going to state a mod_rewrite rule.
Pattern
A regular expression which will be applied to the “current” visible URL (i.e. http://www.yourdomainname.com/search/jewelry.htm)
Substitution
It tells the server how to substitute for the values it recovered from the current url. That is
CODE
http://www.yourdomainname.com/search/jewelry.htm
will be transformed to
CODE
http://www.yourdomainname.com?action = search&category=jewelry
OptionalFlags
This is the only part of the RewriteRule which isn’t mandatory.
Here is a model .htaccess file
CODE
RewriteEngine On
RewriteRule ^search/([^/\.]+).htm$ index.php?action=search&category=$1 [L]
RewriteRule ^search/([^/\.]+).htm$ index.php?action=search&category=$1 [L]
Does it look bit ugly? Not at all, let us see how the server interprets it:
^search/
Directs the server to see whether the requested url starts with search/. If it doesn’t, this rule will be ignored.That is, this rule will track the url like
http://www.yourdomain.com/search/jewelry.htm,
http://www.yourdomain.com/search/pets.htm
http://www.yourdomain.com/search/blaa.htm
([^/.]+)
Here, the enclosing brackets signify that anything that is matched ( and appears after "/") will be remembered by the RewriteRule.
^/. => indicates that it will neither accept a "/" nor a period (.)
=> Whatever else it will get, it will remember that.
So, in our example, it will remember the word jewelry after reading the url
http://www.yourdomainname.com/search/jewelry.htm
$
This symbol indicates the end of string
Now the substitution part contains:
index.php?action=search&category=$1
The actual page which will be loaded by Apache. $1 is magically replaced with the text which was captured previously.
A special substitution is -. This substitution tells Apache to not perform any substitution.
[L]
Tells Apache to not process any more RewriteRules if this one was successful.
Now once you have created your .htaccess file, now you require to modify the links of your webpages in accordance with the new RewriteRules.
That is link like:
CODE
http://www.yourdomainname.com?action = search&category=jewelry
Will be changed to :
CODE
http://www.yourdomainname.com/search/jewelry.htm
To test your .htaccess file, you need to
Open the httpd.conf file and uncomment the following lines (remove the trailing #s):
CODE
#LoadModule rewrite_module modules/mod_rewrite.so
#AddModule mod_rewrite.c
#AddModule mod_rewrite.c
I have shown here a basic example of mod_rewrite rule.
If you feel the need to mod_rewrite your website, then please visit doriat.com.


