944,000 Members | Top Members by Rank

Dec 13th, 2004
0

Can I separate out two domains in the same hosting account with .htaccess ?

Expand Post »
I have searched all around the web for .htaccess tutorials, and there are a lot of them but none seems to offer a solution to this particular problem: I have rented webhosting space and I am running two domains off of one account. The two sites are totally unrelated and I don't want to be able to access the files of one with the domain name of the other. Here's what I mean:

Assume I am running two sites, biology.com and physics.com (just an example), off of my account. The directory structure is like this:

index.php // this file takes all requests and sorts them out by domain name

/biology
/biology/biology-index.php
/biology/biology-page1.php
/biology/biology-page2.php

/physics
/physics/physics-index.php
/physics/physics-page1.php
/physics/physics-page2.php

So the two sites are separated, and when you type in biology.com you get redirected to biology.com/biology/biology-index.php, and when you type in physics.com, you get redirected to physics.com/physics/physics-index.php. That redirection is done with the index.php script and it works like a charm.

BUT, someone could type in biology.com/physics/ and get the physics-index.php page while having the biology.com showing in their browser address. And I have noticed that it doesn't just take someone typing it in like that for it to happen--it has happened as a result of search engine robots that mangle the address, etc.

So is there any way to set up a rewrite condition and rule to prevent any request with a host of biology.com from allowing access to the physics pages, and any request with a host of physics.com from allowing access to the biology pages?

To whomever can solve this, thank you so much, in advance!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
farmhouseboy is offline Offline
3 posts
since Dec 2004
Dec 14th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

Can't you get the DNS to point to the subfolder/index as aposed to your web space root?
Reputation Points: 38
Solved Threads: 9
Posting Whiz in Training
suRoot is offline Offline
210 posts
since Apr 2004
Dec 14th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

Quote originally posted by suRoot ...
Can't you get the DNS to point to the subfolder/index as aposed to your web space root?
No, it doesn't look like i have access to that. I use p4host for my hosting, and the control panel i have access to is called "CPanel". It has a lot of tools, but nothing for fidgeting directly with DNS, so far as I can tell. i can try editing the parked domains entries, but i don't know if that'll do it.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
farmhouseboy is offline Offline
3 posts
since Dec 2004
Dec 14th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

you own the dns so you have to contact your DNS supplier
Reputation Points: 38
Solved Threads: 9
Posting Whiz in Training
suRoot is offline Offline
210 posts
since Apr 2004
Dec 16th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

What are the document roots of the two domains?

Isn't biology.com maps to /biology and physics.com maps to /physics?
If that is the case, you would not be able to access biology.com/* using physics.com as both document roots are different ~

If you are saying they both map to the same directory (/) and under that directory (/), you have /biology and /physics. Then yes you can access files using both domains ~

I think you can use mod_rewrite to handle the root directories of the domains ~ :-|
Reputation Points: 10
Solved Threads: 0
Light Poster
YUPAPA is offline Offline
42 posts
since Dec 2004
Dec 16th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

Quote originally posted by YUPAPA ...
What are the document roots of the two domains?

Isn't biology.com maps to /biology and physics.com maps to /physics?
If that is the case, you would not be able to access biology.com/* using physics.com as both document roots are different ~

If you are saying they both map to the same directory (/) and under that directory (/), you have /biology and /physics. Then yes you can access files using both domains ~

I think you can use mod_rewrite to handle the root directories of the domains ~ :-|
It's the latter case. The document roots of both of them are the same, (/). If I can use mod_rewrite to do it, that would be great. But that's what I would need help on. I don't know what those htacess entries would be.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
farmhouseboy is offline Offline
3 posts
since Dec 2004
Dec 16th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

If you are using cpanel, the easiest thing to do would be to setup an 'addon' domain, assuming they give you the right to do this, basically an addon domain will be a folder in the main domain that the secondary domain will point to.
Moderator
Staff Writer
Reputation Points: 154
Solved Threads: 18
Linux Reject
blud is offline Offline
570 posts
since Apr 2004
Dec 18th, 2004
0

Re: Can I separate out two domains in the same hosting account with .htaccess ?

Here is a mod_rewrite guide you may want to take a look ~
http://httpd.apache.org/docs/misc/rewriteguide.html

I suck at mod_rewrite too ~ :cheesy:
Reputation Points: 10
Solved Threads: 0
Light Poster
YUPAPA is offline Offline
42 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Linux Servers and Apache Forum Timeline: mod_rewrite newbie question
Next Thread in Linux Servers and Apache Forum Timeline: Apache mod_rewrite with Google Ads





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC