SEO Subdomain Routing Techniques and ScriptsSubdomain Routing allow affiliates to display different pages according to Subdomain / Hostname specified in the URL.
Such as: http://overstock-com.anydomain.com
We have decided NOT to use mod_rewrite for this feature because we do not want to increase the complexity of any future mod_rewrite features. We should leave mod_rewrite to do what it does best. This is fairly simple and it is more flexible being able to control it from PHP.
How does this Subdomain Routing work?
Using the global pre-defined server variables from PHP such as $_SERVER['HTTP_HOST'] and $_SERVER['SCRIPT_URI'] which gives us the URL or hostname + domain name of the current page, we parse the information, try to match to an array store names / category names / manufacturer names, then route / include the right PHP page content as needed.
Here is the flow of this concept:
Collecting URL info using $_SERVER['HTTP_HOST']
Parse hostname (subdomain) and domain name
If subdomain is regular such as www or (blank) we skip matching
Try to match subdomain to string or Store Names / Category Names / Manufacturer Names
If match found, it will return the Group = (store / cat1 / mfg) and Number.
Display appropriate content based on Group + Number such as using DFF's new Store Info Tool.
See example below demonstrating subdomain routing for Store = Overstock.com:
Pls analyze the above URL note the subdomain is overstock-com. We use (dash / hyphen) to replace illegal URL characters.
Eventhough the above URL has a PHP file behind the domain name, it can be done without the PHP file where obviously then the index.php will be executed.
Overstock.com does not have Rebates / Deals / Coupons so here are a few more demo:
The above URL has only demonstrated the subdomain using Store Info tool, we will have Category Info and Manufacturer Info tools coming soon also. Of course you can use these tools separately without this subdomain routing functionality.
You can also use subdomain routing with our current tool. Here is an example listing products from 4Inkjets.com:
How to integrate Subdomain Routing?
There are two components needed to make subdomain routing work.
1. PHP codes to be placed on the file which will receive the traffic.
In my example these are merchant_datafeed_script_storeinfo.php and
merchant_datafeed_product_script.php or index.php.
2. Include file which contains strings of Stores, Categories and Manufacturers Names.
This file also contains the matching function used in the PHP code above.
This include file is named: dff_host_match.php
Please note where dff_host_match.php is included in the PHP code above.
Also note where we call the function dff_match_hostname($dff_hostname).
Since the file dff_host_match.php contains thousands of names, DFF servers will generate this file weekly (every Tuesday at 9:30am CST).
3. Subdomain routing require a DNS server A record change. You must Add a WILDCARD A Record into your DNS server for the domain name you are trying to use the subdomain routing with.
Click here to read more about adding WILDCARD DNS A Record.
You will need to download this file and rename it to remove the .txt extension.
Here is the link to download dff_host_match.php:
This new feature is only in Alpha stage, please test, provide comments or any additions we need to improve it.
Why do we need subdomain capability?
For SEO benefits. It is well known that Search Engines highly value keywords in the subdomain and domain name. Many search engines even index subdomains as if it was a separate site.
Integrating this subdomain routing feature will increase your page indexed on search engines and potentialy get higher ranking on search results for Store / Category / Manufacturer Names.
When used well together with Store Info / Category Info / Manufacturer Info / Store Product Pages it will provide additional good content for your web site.
Real subdomain routing example with Source Code: