basic http:// to http://www. rewrite

Using a single web hosting account to host multiple sites

basic http:// to http://www. rewrite

Postby brill.us » Sun Mar 11, 2007 3:02 pm

Hey guys,

this is going to sound dumb... However, here I go:

I've got a domain and some subdomains:

bla.mydomain.com
blabla.mydomain.com

However,

I would like to do:

ONLY mydomain.com to be sent to www.mydomain.com, so no matter what they do it ends up at www.mydomain.com unless its specifically added bla.mydomain.com

Basically mod_rewrite only: from http://mydomain.com to http://www.mydomain.com

then the rest can be left alone ... is that possible?
brill.us
 
Posts: 16
Joined: Sun Mar 11, 2007 2:57 pm

Postby richardk » Sun Mar 11, 2007 3:13 pm

This should do it
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(domain\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby brill.us » Sun Mar 11, 2007 3:34 pm

Thanks man....

I orginally had:

RewriteEngine on
Options +FollowSymlinks
RewriteCond %{HTTP_HOST} !^www\.domain.com [NC]
RewriteRule ^(.*) http://www.domain.com/$1 [L,R=301]

so I was close... just messed up a couple of lines... but that helps tons...

Thanks man!
brill.us
 
Posts: 16
Joined: Sun Mar 11, 2007 2:57 pm


Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 3 guests

cron