Web Hosting Talk







View Full Version : Domain name to point to a subdirectory of a virtual site? Help please.


Paul_M
10-17-2001, 09:24 AM
Here is my problem now. :)

I need to point a domain name to a subdirectory of a virtual site for a project I am doing.

for example the main domain name points to /home/sites/site1/web/

I want the new domain name to point to /home/sites/site1/web/subfolder/

This is so www.domain2.com is actually www.domain1/subfolder, but site visitors will not know this. I realise this is not the best way to have two sites on a RaQ4, but the site is already made on another server, and I'm not keen on changing tonnes of links etc for the new server!

Can I do this at server level (ie with httpd.conf), or do I need to use a .htaccess file?

Either way, what do I need to do?

The site is hosted with verio who are handling the DNS side of things for me.

Paul_M
10-17-2001, 10:58 AM
I have searched all the FAQ's forums etc. I can find with nothing that really answers this question.

Can anyone help at all?

:eek:

Joana
10-17-2001, 11:23 AM
I have not tried this But I think it should work..

-------------------------------------------------------
Add the following to the .htaccess file:

RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.domain.*
RewriteCond %{REQUEST_URI} !/subdir/
RewriteRule ^(.*)$ /subdir/$1
RewriteCond %{HTTP_HOST} ^domain.*
RewriteCond %{REQUEST_URI} !/subdir/
RewriteRule ^(.*)$ /subdir/$1

Replace www.domain.* (4th line) and domain.* (7th line) with the actual domain name of the pointer (minus the 'www.' in the second instance). Do not put .com or .co.uk on it; keep the asterisk. Also replace the four instances of "subdir" with the subdirectory on YOUR site that domain pointer will map to.

This will redirect requests for the domain pointer (both domain.com and www.domain.com) to the directory specified.

Paul_M
10-17-2001, 11:43 AM
Despite setting the AllowOverride to All in access.conf, under directories/home as soon as I put in my own .htaccess file the site stops working.

Any guesses?

:(

Omair Haroon
10-17-2001, 11:48 AM
Hello,

Joana, thanks for the info below. but I think the best way is to modify the httpd.conf.

Here is what you should do:

login to telnet and type su-
Enter root password. Then type:

cd etc/httpd/conf
touch include.conf
pico include.conf

and then type this in the include.conf file

<VirtualHost ip.address.of.maindomain>
ServerName second-domain.com
ServerAdmin admin
DocumentRoot /home/sites/site1/web/subfolder/
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
AddHandler server-parsed .shtml
AddType text/html .shtml
</VirtualHost>

then exit PICO by pressing Ctrl-X and press Y. That would save the file. Next edit the httpd.conf file by typing:

pico /etc/httpd/conf/httpd.conf

and move on the last line by continously pressing Ctrl-V and after the last line press enter and type:

Include include.conf

Press Ctrl-X and press Y to save and exit the file. Now restart the apache server for the site to be active.


That's it. You are done. Let me know if you have any problems.

Paul_M
10-17-2001, 02:02 PM
Thanks, I'll give that a go tomorow and let you know.

:)

Omair Haroon
10-17-2001, 03:38 PM
Sure!

nudetravel
10-17-2001, 05:15 PM
Omair -

would that work with the document root listed as a domain name (on another server)?

What DNS entries would need to be made for the re-directed domain? I would assume just the normal A records to the RaQ?

Thanks

Ryan - Dim8
10-17-2001, 05:44 PM
Hello Omair,

I just tried your method and each time i restart my apache i get the following error -

fopen: No such file or directory
httpd: could not open document config file /etc/httpd/include.conf
/usr/sbin/httpd

does this file need any kind of permissions? or have i not followed your instructions correctly?

Chicken
10-17-2001, 10:55 PM
Originally posted by Ryan - Dim8
httpd: could not open document config file /etc/httpd/include.conf
/usr/sbin/httpd

The file should be:

etc/httpd/conf/include.conf (not /etc/httpd/include.conf) per the instructions above.

If this line at the end of your httpd.conf file (/etc/httpd/conf/httpd.conf) is:

Include include.conf

and it doesn't work, try:

Include ./include.conf

and make sure the file is actually in /etc/httpd/conf
(Meaning the file would be /etc/httpd/conf/include.conf)

Ryan - Dim8
10-18-2001, 03:14 AM
*blushes* it was one of them days, Thank You Chicken.

Omair Haroon
10-18-2001, 07:43 AM
cd etc/httpd/conf
touch include.conf
pico include.conf


:(

Chicken
10-18-2001, 10:22 AM
Originally posted by Ryan - Dim8
*blushes* it was one of them days, Thank You Chicken.

I have had many of 'those days' that you speak of :D

Paul_M
11-01-2001, 08:41 AM
Sorry guys but this does not appear to work.

I had to change the include path to conf/include.conf for it to be found when I restarted server, but still no joy.

The second and third domain names on the virtual site are just taking me to the index page of the main domain on the virtual site.

Can you offer any further advice or help please?

Thank you.

:eek:

Paul_M
11-01-2001, 08:46 AM
The other option is to use a .htaccess file I guess?

What would I have to do to do this? I have tried (as stated above) but with no joy. At the moment both domain names www.domain1.co.uk and www.domain2.co.uk point to the same place, I want domain2 to point to a subdirectory, and also a thrid domain to another.

Again, I know this isn't easy, but it's the only acceptable file structure from where it is currently hosted.

:(

Paul_M
11-01-2001, 09:56 AM
a-ha

Heaven knows what I did, but it worked!

:)

Such is life!

Cheers folks

ASPCode.net
11-01-2001, 02:00 PM
<VirtualHost ip.address.of.maindomain>
ServerName second-domain.com
ServerAdmin admin
DocumentRoot /home/sites/site1/web/subfolder/
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
AddHandler server-parsed .shtml
AddType text/html .shtml
</VirtualHost>


With this config CGI won't work on the subdomain site... CGI Wrap gives an error and I have debugged it and it all makes sense.

The file:

web/subdomain/test.cgi

Get accesses like this
subdomain.yourdomain.com/test.cgi

and this causes CGI Wrap to stop - cant find the file...

You can get it to work by disabling CGI wrap

AddHandler cgi-script .cgi
AddHandler cgi-script .pl
Options Indexes FollowSymLinks ExecCGI Includes

but this is not good enough for me... Anyone else???

I havn't tried Joanas rewrite trick but will asap.

Chicken
11-01-2001, 02:55 PM
Well, obviously there is a permissions problem somewhere. Either the folder or the file is owned by someone that shouldn't own it for it to run in the directory you have put it. Sometimes when you redirect things, this gets a bit crossed, but I'd make sure that the subfolder and file have the same owner as the site admin (of that particular site), and see if that works.

ASPCode.net
11-01-2001, 03:21 PM
Thanks Chicken but that's not it: same owner etc

Here is what happens

http://www.domain.com/folder/test.cgi - WORKS!

http://folder.domain.com/test.cgi - DOES NOT WORK



Execution of (/home/sites/site5/web/test.cgi) is not permitted for the following reason:

Script file not found.


I have debugged it with cgiWrapd and came to the conslusion that it believes the script belongs to www.domain.com ( which it actually does ) and then it just strips the url after domain ( becomes ./test.cgi - which it tries to find in the /home/sites/siteX/web directory...

I have read on the cobalt list that disabling cgi-wrapper is the only way

Chicken
11-01-2001, 03:42 PM
Ahhhh... well I tried, heh...

ASPCode.net
11-01-2001, 03:51 PM
Oh, I've been trying to get around this for a while and now when I saw your post I thought - hey now when Chicken has gotten involved in it a solution will soon be available...

So you are seriously saying there are things you don't know??? I mean, don't ruin my illusion... Well, I guess they say there is no Santa either...

:)

windy723
12-15-2011, 01:17 PM
Hello,

Joana, thanks for the info below. but I think the best way is to modify the httpd.conf.

Here is what you should do:

login to telnet and type su-
Enter root password. Then type:

cd etc/httpd/conf
touch include.conf
pico include.conf

and then type this in the include.conf file

<VirtualHost ip.address.of.maindomain>
ServerName second-domain.com
ServerAdmin admin
DocumentRoot /home/sites/site1/web/subfolder/
AddHandler cgi-wrapper .cgi
AddHandler cgi-wrapper .pl
AddHandler server-parsed .shtml
AddType text/html .shtml
</VirtualHost>

then exit PICO by pressing Ctrl-X and press Y. That would save the file. Next edit the httpd.conf file by typing:

pico /etc/httpd/conf/httpd.conf

and move on the last line by continously pressing Ctrl-V and after the last line press enter and type:

Include include.conf

Press Ctrl-X and press Y to save and exit the file. Now restart the apache server for the site to be active.


That's it. You are done. Let me know if you have any problems.

Thanks Omair! It's really worked with your code above.