Coming off of Dynamic Subdomains

Using a single web hosting account to host multiple sites

Coming off of Dynamic Subdomains

Postby p0lar_bear » Wed Jul 23, 2008 2:23 pm

I'm stopping use of dynamic subdomains on my site; never really used them to their fullest.

What I want to do is make it so if a user types in subdomain.domain.com, it will drop the subdomain and replace it with a www, unless it's an actual subdomain on the site.

This is what I have so far, I'm stumped (regexp sucks so hard %-(). M I doin it rite? It recognizes real subdomains, but it doesn't change the URL in the user's browser.

Code: Select all
Options +FollowSymLinks

# Turn on mod_rewrite
RewriteEngine On

# Rewrite sub domains.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{HTTP_HOST} !^(www\.|mail\.|blogs\.)?website\.net$ [NC]
RewriteCond %{HTTP_HOST} ^(www\.|mail\.|blogs\.)?([^\.]+)\.website\.net$ [NC]
RewriteRule ^.*\.website\.net/(.*)$ %{HTTP_HOST}www\.website\.net/$1 [QSA,L,R]
p0lar_bear
 
Posts: 1
Joined: Wed Jul 23, 2008 2:13 pm

Postby richardk » Thu Jul 24, 2008 1:27 pm

You want to match all sub domains except www, mail and blogs and redirect them to www?
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Make sure it's not www, mail or blogs.
RewriteCond %{HTTP_HOST} !^(www|mail|blogs)\.example\.net$ [NC]
# Redirect to www, passing on the path.
RewriteRule ^(.*)$ http://www.example\.net/$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 19 guests

cron