How do I redirect an Addon domain to a folder?

Category: How To

dubosqued
Asked:
2013-09-11 9:03 am EST

Hits: 1,222
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?

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by User

0

JacobIMH
Staff
5,603 Points
2013-09-12 3:01 pm EST
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

You must login before you can post a comment about this answer.

Hi Jacob,

thanks for taking the time to answer. Let me use specifics then, since your discussion is a bit over my head. The discussion I saw elsewhere of the rewrite rule left me confused, since I know nothing about whatever language Apache uses.

Our account with InMotion is drawbooks.com. I have an add-on domain (actually now a parked domain after several chats with Tech Support) called peelbooks.com. .... Sorry this is all glommed together; how do you make paragraphs here?

I have—for the time being—both a file peelbooks.html in the root directory of drawbooks.com, and an identical file called index.html in a subdirectory called peelbooks. I'd like someone typing "peelbooks.com" to go to one or the other (preferably the file in the root directory) to get the page with the browser showing "peelbooks.com" instead of "http://drawbooks.com/peelbooks.html." --- Sorry this is all glommed together; how do you make paragraphs here?
dubosqued
48 Points
2013-09-12 6:22 pm EST
Hello dubosqued, and thanks for your reply.

So it does sound like you need an addon domain, and not a parked domain.

Parked domains


As an example, you have drawbooks.com. This is your primary domain name, and as such, any parked domains you add to your site will reflect this exact same website content as well.

So if you had drawbooks.tld with .tld being any other Top Level Domain like .net, .org, .us and so on, you'd add those as parked domains.

Addon domains


An addon domain is a separate domain from your primary one, and points to a completely different folder on your hosting account. I've gone ahead and removed peelbooks.com as a parked domain, and added it back as an addon domain. Now anytime you go to that website it's going to pull from your /public_html/peelbooks/ folder, instead of your root web folder where your primary domain pulls from.

Image and resources paths


Now with the way you designed the index.html page within the /peelbooks/ directory, it would throw 404 not found errors for your images and CSS files. So I went ahead and copied over the folders /public_html/assets/ and /public_html/images/ over to /public_html/peelbooks/ so that works as well.

I also re-named your /public_html/peelbooks/.htaccess file to .htaccess-BAK so it's not active. As the way it was trying to handle redirections was causing it to put drawbooks.com/peelbooks back in the address bar.

It looks like you were able to successfully make paragraphs here in your comment, you just simply hit Enter twice to start a new paragraph much like a text editor.

Hope that cleared things up for you. If you had any further questions please let us know!

- Jacob
JacobIMH
5,603 Points
Staff
2013-09-13 12:27 pm EST
Jacob, thank you so much for doing on so I could follow the example. I spent a fair amount of time on the phone as well with tech support. Turns out I had hotlink blocking on at drawbooks.com, which had the predictable result of serving no images for one add-on domain...except that it let another have them with no problem. The same was true with using "../images/" to access images on drawbooks.com...seems like sometimes it worked, sometimes it didn't. I finally moved images and assets to individual add-on domain folders, and now all is well....
dubosqued
48 Points
2013-09-13 4:45 pm EST
Hello again dubosqued,

You are quite welcome, I wanted to try to explain things as fully as possibly to steer you in the right direction as I know it can get confusing sometimes with so many options.

I'm really glad things are working for you now how you wanted, if you run into any other snags please let us know!

- Jacob
JacobIMH
5,603 Points
Staff
2013-09-14 7:11 am EST

OTHER ANSWERS

0

johnpaulb-imhs1
Staff
5,444 Points
2013-09-11 10:00 am EST
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

You must login before you can post a comment about this answer.

You misread my question. I am quite familiar with managing redirections. No, the answer is there is no way to do domain masking except through a name server using a URL frame, but the result may not be readable by many moble devices.
dubosqued
48 Points
2013-09-11 1:24 pm EST
Like this Question?
Write New!
Do you want to publish a tutorial to our support center?

News / Announcements

SSL Certficate Warnings
Updated 2014-04-14 11:34 am EST
Hits: 2230
Heartbleed 0-day OpenSSL security bug
Updated 2014-04-14 04:43 pm EST
Hits: 5654

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!