| | |
Can I separate out two domains in the same hosting account with .htaccess ?
![]() |
•
•
Join Date: Dec 2004
Posts: 3
Reputation:
Solved Threads: 0
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!
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!
•
•
Join Date: Dec 2004
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by suRoot
Can't you get the DNS to point to the subfolder/index as aposed to your web space root?
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 ~ :-|
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 ~ :-|
•
•
Join Date: Dec 2004
Posts: 3
Reputation:
Solved Threads: 0
•
•
•
•
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 ~ :-|
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:
http://httpd.apache.org/docs/misc/rewriteguide.html
I suck at mod_rewrite too ~ :cheesy:
![]() |
Similar Threads
- sell domains and hosting (Web Hosting Deals)
Other Threads in the Linux Servers and Apache Forum
- Previous Thread: mod_rewrite newbie question
- Next Thread: Apache mod_rewrite with Google Ads
| Thread Tools | Search this Thread |
.net apache asus bbc bluegene centos cisco citrix cloud cloudcomputing datacenters debian dell desktops development distributions distros drivers economy eeepc energy enterprise fedora gadgets gentoo gos government gpl hardware hp hyper-v ibm java jobs kindle knoppix kvm laptop laptops lawsuits licensing limo linustorvalds linux linuxfoundation linuxmagazine magazines microserver microsoft mobile mobilephones netbook netbooks news novell olpc open openmoko openoffice opensolaris opensource opensuse openvz operatingsystems os patents pc pcworld plathome politics print qumranet redhat rhel robot russia sco server servers slackware software solaris source sun supercomputer support tivo torvalds tradeshows training tv ubuntu umpc unix virtualization vmware windows x86 xandros xen





