Display content as root from subdomain

Tag: .htaccess Author: zy_wu Date: 2009-11-23

I have a site running on a subdomain of new.site.com and I want to be able to just put something in the .htaccess file that will display the subdomain's content as if it was in the root.

Where the site is: new.site.com The url that I want to use: site.com

Basically what I want to do is just not move the files from the subdomain to the root of my server.

I would suggest sending a redirect response (301 or 302) so the user is sent to site.com. Google may penalize you if it detects the same content in multiple places, so redirecting to the canonical location may be preferable.
I current have a 301 setup but the URL changes to the subdomains URL. I need to just display the content that is at subdomain but make it appear it is at the root level.

Other Answer1

Try using a domain pointer.

EDIT: Not sure why my answer was downed. Let me elaborate a little more.

I do this myself on my websites. In my hosting company's control panel, I have the option to create domain pointers. What this does is set a domain to use the website of another domain.

comments:

I didn't down it but I'm not sure how to do that in cPanel. All I have the option to do is create redirects.
Can you create addon domains? I believe that's how cPanel does it. (I just logged into one of mine).
It gave me an error saying that I can't park my main domain. Do I have to remove the 301 redirect first?
Okay, I see the problem now. I had the two flipped. I thought you were trying to point your sub-domain to your root. I'm so sorry about that. I can't find any way to do what you're talking about. I think the best way would be to move the files. Really easy in FileZilla, though, unless you have DB pointers that are domain specific. :-) If you still need to keep the subdomain intact, though, you could create a pointer like we talked about.

Other Answer2

Actually found this that works incase anyone was wondering:

RewriteEngine on
RewriteBase /
RewriteRule ^$ /subdomain/ [L]