301 Redirect Domain to Sub-domain?

Howdy,

LINUX SERVER

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

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

OR

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.

Thanks-
LVL 9
pmagonyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ravenplConnect With a Mentor Commented:
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]
0
 
ravenplCommented:
Yes, it's possible,

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

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

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.
0
 
ravenplCommented:
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?
0
 
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:
67.35.122.80 - - [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:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11"
0
All Courses

From novice to tech pro — start learning today.