Redirecting non-existant subdomains to www

Using a single web hosting account to host multiple sites

Redirecting non-existant subdomains to www

Postby Moguai » Mon Oct 15, 2007 2:05 am

So, I'm in a unique perdiciment; we used to use subdomains for everything until I learned more about webscores and subdomains being handled as separate entities. So we moved everything to pack on top of the primary domain(s).

So now I have all of these subdomains that are indexed by search engines and are bookmarked that have been crawled by major engines that now allow users in on the subdomains vs them accessing on our primary (which gets to be an issue with cross domain cookie issues on our forum).

What I'd like to do is have all (nonwww) requests to a subdomain sent to my www version of the site (so things will reign sane).

One thing i'd like, as I have multiple tld's, is have it so that if someone where to access chat.mysite.com be sent to www.mysite.com AND chat.mysite.net be sent to chat.mysite.net (preserving the tld's).

hoping for any ideas and assistance :).

PS, any subdomain that would be directed to my web-root will be classified as "non existant", any subdomains go elsewhere on the server.
PPS, I'm looking for a .htaccess solution vs a httpd.conf solution.
Moguai
 
Posts: 2
Joined: Mon Oct 15, 2007 1:55 am

Postby richardk » Tue Oct 16, 2007 7:56 am

Try (instead of the one in this post)
Code: Select all
Options +FollowSymLinks

RewriteEngine On

Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.([a-z0-9]\.(com|net|org|info|us|ws))$ [NC]
RewriteCond %{HTTP_HOST} ^(.*\.)?([a-z0-9]\.(com|net|org|info|us|ws))$ [NC]
RewriteRule ^(.*)$ http://www.%2/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 26 guests

cron