Pointing and cloaking folders to separate domains

Using a single web hosting account to host multiple sites

Pointing and cloaking folders to separate domains

Postby pr0fess0r » Mon Feb 02, 2009 6:53 pm

Hi Guys, thanks for reading.. I'm new to mod_rewrite and have an interesting challenge.

I have a dedicated Lunarpage server with a number of domains on it. One main domain links out to these other sites. My client now wants all of the other sites to appear as folders under the Master domain... i.e.

masterdomain.com/visit displays visitdomain.com
masterdomain.com/work displays workdomain.com
etc

So that masterdomain.com/work/hello.php displays workdomain.com/hello.php
and
masterdomain.com/work/news.php/news/headline displays workdomain.com/news.php/news/headline
and so on. So the original domain is cloaked.

I could move the contant from all of these domains into the relevant subfolders and update config files and so on, but is there an easier way to do this with .htaccess and mod_rewrite / mod_proxy if all the sites are on the same server?

many thanks for any advice offered

Cheers

Lucas
pr0fess0r
 
Posts: 7
Joined: Mon Feb 02, 2009 6:41 pm

Postby richardk » Tue Feb 03, 2009 11:18 am

What are the document roots?
Do you want masterdomain.com/work or workdomain.com to be displayed in the address bar of the browser?
Can you create Symbolic Links?

I could move the contant from all of these domains into the relevant subfolders and update config files and so on, but is there an easier way to do this with .htaccess and mod_rewrite / mod_proxy if all the sites are on the same server?

The easier way is not always the best way and it probably won't be easier. It should just be a case of changing the DocumentRoots of the domains or creating two Aliases (depending on the answer to the second question).
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pr0fess0r » Tue Feb 03, 2009 1:00 pm

Hi, thanks for your feedback.
The document roots would be:

masterdomain.com/work
/var/www/vhosts/masterdomain.com/httpdocs/work

workdomain.com
/var/www/vhosts/workdomain.com/httpdocs/

They'd like masterdomain.com/work/whatever in the address bar of their browser, even though the site is workdomain.com/whatever

I have root access to the server and could make changes if needed... could you give me an example of the aliases I'd need to set up?

Thanks again

Lucas
pr0fess0r
 
Posts: 7
Joined: Mon Feb 02, 2009 6:41 pm

Postby richardk » Wed Feb 04, 2009 11:29 am

In masterdomain.com's <VirtualHost>
Code: Select all
Alias /work /var/www/vhosts/workdomain.com/httpdocs


Then you might want to redirect workdomain.com requests to masterdomain.com/work. In /var/www/vhosts/workdomain.com/httpdocs/.htaccess
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?workdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.masterdomain.com/work/$1 [R=301,L]

(This could also be done slightly differently with <VirtualHost>s.)
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pr0fess0r » Wed Feb 04, 2009 12:26 pm

That's awesome :) I'm just finding out from Lunarpages how to do that as the httpd.include files are managed by Plesk and frequently overwritten, I'm just finding out where I can make the VirtualHost change but your solution looks great! I'll let you know how it goes :)
Cheers

Lucas
pr0fess0r
 
Posts: 7
Joined: Mon Feb 02, 2009 6:41 pm

Postby pr0fess0r » Mon Feb 09, 2009 12:30 pm

Hi again
I set this Alias up in vhost.conf and when I browse masterdomain.com/work I'm prompted to download a file of type x-httpd-php which I assume is my index.php file from workdomain.com... Apache doesnt seem to want to serve the file properly... what am I doing wrong?
Cheers
pr0fess0r
 
Posts: 7
Joined: Mon Feb 02, 2009 6:41 pm

Postby richardk » Tue Feb 10, 2009 2:17 am

Does PHP work on the master domain?
Are you using FastCGI or mod_php?
You might need to add a directive (possibly AddHandler) to tell Apache hw to handle the PHP files.

You'd be better off asking your host as they knowhow this is set up.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pr0fess0r » Tue Feb 10, 2009 11:17 am

Thanks ... actually my hosting company said something very similar and suggested:
AddHandler application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
AddType application/x-httpd-php5 .php5 .php4 .php .php3 .php2 .phtml
Alias /work /var/www/vhosts/workdomain.com/httpdocs

But when browsing http://masterdomain.com/business I'm now prompted to download a file of type x-httpd-php5... so I'll keep investigating and if I find a solution I'll let you know (any further ideas welcome:)
Cheers
pr0fess0r
 
Posts: 7
Joined: Mon Feb 02, 2009 6:41 pm

Postby richardk » Tue Feb 10, 2009 11:54 am

You could try setting up a Symbolic link instead of an Alias.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby pr0fess0r » Tue Feb 10, 2009 12:22 pm

Hi

ln -s /var/www/vhosts/workdomain/httpdocs /var/www/vhosts/masterdomain/httpdocs/work gives me a 403 forbidden error browsing http://masterdomain/work
Any idea why this would be?
Thanks for your continued help :)
pr0fess0r
 
Posts: 7
Joined: Mon Feb 02, 2009 6:41 pm

Next

Return to Domain Handling

Who is online

Users browsing this forum: No registered users and 19 guests

cron