geenee Posted August 30, 2008 Share Posted August 30, 2008 Hi, firstly apologies if this problem has already been answered or is really simple, I've looked around a lot and can't find a solution. In a nutshell I have domain1.com as my main domain and domain2.com, domain3.com etc - and one hosting account. I'm trying to get them to appear as seperate websites but reside on the same hosting account. I've been using CPanel to try and set this up so far. I can set it up so domain2.com will re-direct to domain1.com/domain2 - or domain2.domain1.com, or even 'mask' domain2.com so it uses the same root directory as domain1.com and all the links appear to be a different web site (e.g www.domain1.com/page2.html and www.domain2.com/page2.html are the same page but appear differently in the address bar). What I want is domain2.com to be a different website to domain1.com, but store the files for domain2.com in a folder (domain1.com/domain2) - so if the user types in www.domain2.com/page2.html they won't get re-directed but the file will be stored here: domain1.com/domain2/page2.html Does this make sense? and is it possible? Looking around I've seen a people referring to cloaking and masking scripts, is this the only - or best way to do this? Here is what is currently in my .htaccess: RewriteEngine on RewriteCond %{HTTP_HOST} ^domain2.com$ [OR] RewriteCond %{HTTP_HOST} ^www.domain2.com$ RewriteRule ^(.*)$ "http\:\/\/www\.domain1\.com\/domain2\/" [R=301,L] The other option I have is to set up seperate hosting accounts for each of my domains, which for various reasons isn't what I'd like to have to do. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/122011-multiple-domains-which-dont-point-to-folder-or-subdomain/ Share on other sites More sharing options...
geenee Posted August 31, 2008 Author Share Posted August 31, 2008 Ok after a long while looking around I've found some code which works if you put it in the .htaccess file of the public_html of the main domain (which would be domain1.com in the above example). Could anyone tell me how this is actually working? I've fiddled around with it, deleted bits to see what happens but really have no idea why this works... RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/domain2/ RewriteCond %{HTTP_HOST} ^domain2.com$ [OR] RewriteCond %{HTTP_HOST} ^www.domain2.com$ RewriteRule ^(.*)$ domain2/$1 [L] Quote Link to comment https://forums.phpfreaks.com/topic/122011-multiple-domains-which-dont-point-to-folder-or-subdomain/#findComment-630378 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.