301 Redirect Domain to Sub-domain?



Is it possible to 301 redirect a domain to a sub-domain within the main domain?

redirect 301 / http://www.subdomain.com/


www.domain.com to www.subdomain.com

we have a fully qualified domain name that is an ADD ON domain under our hosting plan.  Done so that individual hosting for each domain is negated.  However, we'd like to take the main domain and redirect it permanently to the sub-domain.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Yes, it's possible,

Redirect permanent / http://www.subdomain.com/

put it within <VirtualHost >, <Directory > or /document/root/.htaccess
pmagonyAuthor Commented:

In my .htaccess file I entered this and uploaded it to root:

redirect 301 / http://www.subdomain.com/

Produces an error: page cannot be displayed.
Maybe You not allowed to override FileInfo
Can You verify that in apache's error log?
Also, do subdomain is the same virtualHost (documentRoot) as basedomain?
pmagonyAuthor Commented:
"Also, do subdomain is the same virtualHost (documentRoot) as basedomain?"

Yes... it's a folder in the root. It's also been setup as a subdomain.domain.com.

Browser Error:

The page isn't redirecting properly
Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

Server Error Log: - - [30/Jan/2008:13:28:14 -0800] "GET / HTTP/1.1" 304 - "http://www.domain.com/" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: Gecko/20071127 Firefox/"
OK, so what You want is to change the browser's address bar, but the website is the same - right?

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com
RewriteRule .* http://www.subdomain.com%{REQUEST_URI} [L,R=301]

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.