Pointing URL from non-www to www
There is a second approach where pointed domains and subdomains become automatic, meaning no specific code is required for each pointer. While this method is much easier to use and does not need to be modified when adding more domains or subdomains, 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 (except www if used).
You must create a subdirectory under htdocs with a - at the front for every domain and subdomain you wish to be pointed. The directory name must match the first argument in the url (except for www if used). For example, domain.com would have htdocs/-domain and sub.domain.com would have htdocs/-sub and domain2.com would have htdocs/-domain2 etc.
The first argument in the url, and therefore the directory name, must be unique. You cannot have two subdomains with the same name. sub.domain1.com and sub.domain2.com will both go to the directory htdocs/-sub
You cannot have any other directory names that start with a - character.
It defaults to allow www. as a prefix on any domain or subdomain.
The htdocs directory 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 htdocs.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/-
RewriteCond %{HTTP_HOST} ^(www\.)?([^\.]+)
RewriteCond %{DOCUMENT_ROOT}/-%2 -d
RewriteRule ^(.*)$ -%2/$1 [L]
The htaccess code works this way. The first two lines set up the Apache server rewrite process. The first RewriteCond allows www. to be a prefix and captures the request name. The second RewriteCond checks for the existence of a subdirectory with the request name. The third RewriteCond ensures we are not caught in a looping operation. The RewriteRule rewrites the request with the subdirectory name (which was already verified).
Random Post
Related Articles
- Auto post to Blogger with PHP
- Blogger team warning Spam posts
- Domain tips: Domain and subdomain pointing
- 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,802 views
- Invalid Clicks Contact Form: How to contact to Google Adsense support Team - 1,274 views
- Auto post to Blogger with PHP - 1,250 views
- Adsense launching “Category filter Beta” - 1,204 views
- Tutorial: IPSec Security structure - 1,197 views
- How to SEO Copywrite - 1,148 views
- Free Auto Blogger: Auto post rss feed - 1,062 views
- SEO with Site Address / URL - 1,040 views
- How to Use Western Union quick cash at Google Adsense ? - 963 views
- How to Prevent Spam VBB with GeoIPCountry - 922 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