How do I redirect an Addon domain to a folder?

Avatar
  • Answered
I am redirecting site2.com to site1.com/site2/index.html, but want the result to display site2.com in the browser. What do I put in the .htaccess file?
Avatar
JacobIMH

Hello dubosqued,

If you could please clarify a bit what you're exactly trying to accomplish we might be able to steer you in the right direction.

Setting up an addon domain

With your example of site2.com being shown in the address bar, but actually pulling the content from site1.com/site2/index.html this would be accomplished like John-Paul said by setting up an addon domain.

In your example, site1.com would be a primary domain name. That means that the files for this domain would be pulled from your account's default document root which would be the /public_html/ directory located at:

/home/userna5/public_html/

When you access site1.com/site2/index.html in your web-browser, this would allow you to pull up the addon domain's files over the site1.com domain.

However if your end goal is to display that index.html file from the /public_html/site2/ directory, while leaving site2.com as the domain in the address bar, then you'd simply setup site2.com as an addon domain, and make its document root /home/userna5/public_html/site2/. You can always modify your addon domain's document root as well.

If you can give us an exact use case for what you're trying to do instead of this, we might have another suggestion to offer. But typically this is how having multiple domains on an account functions.

Using .htaccess RewriteRule to point to different file

When you start using .htaccess and a RewriteRule rule , these can not cross domains unless using mod_proxy with Apache, but I'm not sure it sounds like that'd work for you, as along with name server domain masking, you can have problems with search engine optimization and display issues on mobile devices , when trying to do things across domains.

You can however point your RewriteRule to a different physical location on your account. But the only way I can think of this being used would be the opposite of your request. For instance if you didn't actually have a site2.com site setup with the root of /public_html/site2/ physically existing on the server, you could use site3 to point to a file there.

Basically with this you could make it so when people type in site1.com/site3 that the address bar stays at the site1.com/site3 address. But it's actually pulling the content from /public_html/site2/index.html.

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/site3
RewriteRule .* /site2/index.htm [L]

If you actually have the physical /site2/ directory on the server, then you'd need to use something like /site3 in the ReriteCond. Because it's a physical directory it would simply load up that directories Index file from Apache, rather than paying attention to your .htccess rules.

Anyways I hope this information was helpful and answered your question. If you'd like to give us a bit more specifics of the problem you're trying to solve we can take another look for you.

- Jacob

Avatar
johnpaulb-imhs1

Hello dubosqued,

Thank you for your question. The easiest way to accomplish this, is to Addon the domain: site2.com, and in the Document root field enter the folder location for:

site1.com/site2

This will cause the new site to load from that folder.

If you still want to do this using an .htaccess rule, I recommend this article I found via google search.

If you have any further questions, feel free to post them below.

Thank you,

-John-Paul