Domain tips: Domain and subdomain pointing
The examples below assume that your root public directory (where you would put this .htaccess file) is htdocs, which is the default setup for Apache. If your setup is different, then you may need to adjust the examples accordingly.
This approach has you code the first part of the domain or subdomain name and the associated subdirectory in your .htaccess file. For example:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteCond %{HTTP_HOST} ^(www\.)?name\.
RewriteRule ^(.*)$ subdirectory/$1 [L]
Note the second line has name, NOT name.com. And note that there are some restrictions when using this method.
Domains and subdomains are treated exactly the same. The pointing is based on the first argument of the url. In this example name.com (as a pointed domain name) or name.domain.com (as a pointed subdomain) ends up at htdocs/subdirectory. This is particularly useful in certain situations, for example if you want the subdomains of more than one domain to point to the same place, or if you have both a .com and a .net domain name you want pointed to the same place.
You must create a subdirectory under htdocs for every domain and subdomain you wish to be pointed. The subdirectory name is then coded into the htaccess file.
The first argument in the url must be unique. You cannot have two domains or subdomains with the same name. sub.domain1.com and sub.domain2.com will both go to the same subdirectory.
It defaults to allow www. as a prefix on any domain or subdomain.
The root directory with this htaccess file is the “drop through” for any domain or subdomain not found. You may want to put an error not found page as the default page. Or, you could choose to have your main website be the “drop through” and just leave that one in the root.
There is also a simplified variation of this method that can be used in less complex situations where you are simply pointing a domain name and want ALL subdomains of that one domain to be pointed to a specific directory. In this example name.com and any subdomain (including www) of that domain would be pointed to htdocs/subdirectory:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/subdirectory/
RewriteCond %{HTTP_HOST} name.com$
RewriteRule ^(.*)$ subdirectory/$1 [L]
In both examples, the htacess code works this way. The first two lines set up the Apache server rewrite process. Then you have two RewriteCond statements and a RewriteRule for EACH domain or subdomain you wish to point.
Random Post
Related Articles
- Auto post to Blogger with PHP
- Blogger team warning Spam posts
- Pointing URL from non-www to www
- How to get targeted website traffic
- How to setup POP3 Yahoo for business ?
- How to setup POP3 yahoo mail ?
- How to setup Google Apps mail services
- 6 step to setup Google Apps
- How to setup Google Apps mail for company ?
Recent Posts
- Free Panda Internet Security 2010: Windows 7 Launch Party
- FREE 1-year license of Kaspersky Internet Security 2010!
- Warning hack password Yahoo mail !
- How to Use Western Union quick cash at Google Adsense ?
- Western Union available in VietNam
- Facebook for Nokia phones
- DailyMotion now offering Embed HD Video Players
- Free Adword voucher $50
- How to create Shortlinks with Google Apps
- Auto post to Blogger with PHP
- Free Auto Blogger: Auto post rss feed
- The Google Analytics API and PHP
- Using the Google Analytics API - getting total number of page views
- Google Analytics PHP API class
- Blogger team warning Spam posts
- Adsense launching “Category filter Beta”
- Alternatives to Google Adsense by other programs
- What is Adsense Smart Price ?
- How to avoid Adsense Smart Pricing ?
- How to use Adsense again if get banned
Recent Comments
- Patrik
in Warning hack password Yahoo mail ! - Nancy
in Auto post to Blogger with PHP - Tony M J
in DailyMotion now offering Embed HD V… - fonfenVak
in Enable Ping track in wordpress - DaiVyCorp - Int…
in My Google AdSense Account Is Disabl… - DaiVyCorp - Int…
in My Google AdSense Account Is Disabl… - AlexAxe
in VPN Protocols - jennefoh
in Make more money: YouTube Videos Com… - GlenStef
in VPN Protocols - DaiVyCorp - Int…
in Why should I use proxy servers ?
Most Commented
- Top 10 ways to boost alexa ranking (4)
- How to Boost Alexa Ranking (4)
- VPN Protocols (4)
- Make more money: YouTube Videos Coming to AdSense (2)
- My Google AdSense Account Is Disabled (2)
- Top 10 secrets success with business online (1)
- SEO with Site Address / URL (1)
- Free Ways to Increase Your Blog Traffic (1)
- How to SEO wordpress, The Complete Guide (1)
- Manual Unzip Server Command (1)
Most Viewed Post
- Top 10 ways to boost alexa ranking - 1,582 views
- Invalid Clicks Contact Form: How to contact to Google Adsense support Team - 1,184 views
- Adsense launching “Category filter Beta” - 1,177 views
- Auto post to Blogger with PHP - 1,146 views
- How to SEO Copywrite - 1,111 views
- Tutorial: IPSec Security structure - 1,108 views
- SEO with Site Address / URL - 1,009 views
- Free Auto Blogger: Auto post rss feed - 948 views
- How to Prevent Spam VBB with GeoIPCountry - 883 views
- How to Use Western Union quick cash at Google Adsense ? - 876 views
Categories
- How to (51)
- SEO (33)
- Google adsense (31)
- Business land (13)
- Security Policies (21)
- Tips (26)
- Technology news (7)
- Traffic guide (9)
- Top secrets MMO (6)
- Tutorials (10)










No Comment
Leave Your Comments Below