Forum Moderators: phranque

Message Too Old, No Replies

Questions about subdomains and paths.

         

Linda_A

10:34 am on Jun 27, 2004 (gmt 0)

10+ Year Member



Not quite sure which forum these questions fit into, so apologies if this is the wrong one.

My site consists of four related but still fairly distinct sections, so I am considering asking my host to point a subdomain to each sections subfolder. However, I am bit uncertain about how subdomains work when it comes to paths to images, files, scrips, etc.

Lets say I have [domain.com...] and currently the setup is [domain.com...] and [domain.com...] If I turn section1 and section2 into subdomains, I know that I cannot use relative paths any longer. I can't, for example, use ../Graphics to get to [domain.com...] from [section1.domain.com...] any longer. But that's about as much as I know about it, so I have a few questions about other scenarios.

1) Absolute paths: I have been told that each subdomain essentially becomes its own root, so that a root relative path of /Graphics won't work either from one of the subdomains. Is this correct? Or is there any way to use absolute paths across subdomains? One of my scripts (a hit/referral counter) needs to be included using a PHP include, and so far I have only managed to get this to work using an absolute path, not a full server path.

2) Full server paths: Will these still work across subdomains? I probably wouldn't use these for graphics, but I could see using them for scrips or any server wide-includes if they can be used across subdomains.

3) The cgi-bin: Currently, I don't use one for my scripts, but I do have access to one. If I were to move my scripts to it, would all of the subdomains be able to access it. And would it have to be a full server path or not?

4) Actual domains pointed to subfolders of the main domain: I am considering having a second actual domain pointed to a subfolder on my current site. Would paths and such work essentially like for a subdomain, or would there be additional complications? Could it, for example, use the cgi-bin, or does it need its own?

netscan

12:39 pm on Jun 27, 2004 (gmt 0)

10+ Year Member



<quote>1) Absolute paths: I have been told that each subdomain essentially becomes its own root, so that a root relative path of /Graphics won't work either from one of the subdomains. Is this correct? Or is there any way to use absolute paths across subdomains? One of my scripts (a hit/referral counter) needs to be included using a PHP include, and so far I have only managed to get this to work using an absolute path, not a full server path.</quote>

Absolute paths would be relative to the subdomains' folder

<quote>2) Full server paths: Will these still work across subdomains? I probably wouldn't use these for graphics, but I could see using them for scrips or any server wide-includes if they can be used across subdomains.</quote>

The server paths would be the same with the addition of the folder, ie: /current-server-path/subdomain-folder/

<quote>3) The cgi-bin: Currently, I don't use one for my scripts, but I do have access to one. If I were to move my scripts to it, would all of the subdomains be able to access it. And would it have to be a full server path or not?</quote>

You would have to use the server path in the scripts for all domains to access it (if your using separate folders when pointing the domains), however you probably can just create another sub-folder in the same directory that your subdomain is pointing, the scripts would then work relative to that subdomain, but the main domain would need add the folder name when accessing them.

<quote>4) Actual domains pointed to subfolders of the main domain: I am considering having a second actual domain pointed to a subfolder on my current site. Would paths and such work essentially like for a subdomain, or would there be additional complications? Could it, for example, use the cgi-bin, or does it need its own?
</quote>

Same as above, it can have its own cgi-bin or could use server paths. As for accessing the site, it would be the same as if it was on its own root directory, ie: If www.2nddomain.com points to a folder /new-domain/ , the folder /new-domain/ becomes in essence " / " for that domain.

Hope that helps a little....

Linda_A

7:23 pm on Jun 27, 2004 (gmt 0)

10+ Year Member



Not quite sure if I am understanding this correctly, but lets see ...

1) Okay, so absolute paths treat the subdomain folder as root, just like if it was a second real domain pointed to a folder.

Is it possible to use redirects or some other method to get around this for those situations when you cannot use a full server path? For example, the script I am calling via PHP needs to be called with virtual(), and it won't take full server paths, only absolute paths.

2) This I didn't quite follow. Lets say I have a subdomain pointed to [domain.com...] I also have a folder for scripts at [domain.com...] Can I not reference a script in the Scripts from a file in the Subdomain folder even if I use a full server path? As in, calling the script with /home/sites/<site>/www/html/Scripts/?

3) I don't quite follow this bit: '...however you probably can just create another sub-folder in the same directory that your subdomain is pointing, the scripts would then work relative to that subdomain, but the main domain would need add the folder name when accessing them'

However, from your response, it seems as if full server paths should work across subdomains as well, regardless of whether the scripts are in a regular folder (for example, [domain.com...] or in a cgi-bin.

The only other thing I am a bit uncertain about still is whether calling a script that resides in the cgi-bin would require full server paths or could use only /cgi-bin/<file> when subdomains are involved? The way it looks on the server, the cgi-bin is technically below root anyway (the cgi-bin is located at /home/sites/<site>/www/cgi-bin/ and document root at /home/sites/<site>/www/html/), so I thought that using just /cgi-bin/<file> would work.

4) Thanks, I think I see how this works. :)

netscan

9:37 pm on Jun 27, 2004 (gmt 0)

10+ Year Member



1) The absolute paths would start with the root of the subdomain, which would be whatever folder you have it pointing to, so your script would have to reside in a child folder relative to that domain.

2) Yes, you can call it using the full server path from any folder, regardless of where the domain points.

3) Right, if your script needs to work across both of the domains, then you can use the full server path to call them from either. You can try referencing just /cgi-bin/ and see if it works for both domains, if it doesn't, use the server path. I guess it would depend on how your particular server is set up.

4) Any time :)

Linda_A

9:49 pm on Jun 27, 2004 (gmt 0)

10+ Year Member



Thanks, now I think I have a decent grasp of this. Well, at least I know that when all else fails, use server paths to make certain things will work. ;)

Now I just need to figure out how to get my referral script included using a server path, since an absolute path won't work once I get the subdomains installed. :)