/    Sign up×
Community /Pin to ProfileBookmark

Path To Scripts & Images On Apache

Hi All,

I have a bit of an odd question, so if this is not the right place to ask it, then my apologies.

My site is hosted on an apache server. I want to set up a subdomain that accesses scripts in the top level domain.

Apache sets up the site with a public_html folder. domain.com would have its index file in the public_html folder.

The path to that public_htlm folder would be “/home/username/public_html/”. Therefore, to access a file in the admin folder in public_html, the path would be “/home/username/public_html/admin/”.

When Apache creates a subdomain, say [url]www.test.domain.com[/url], it creates a folder (test) in public_html. Curiously, the path to admin works from the subdomain for “/home/username/public_html/admin/connect.inc.php”, but it doesn’t work for scripts or images.

I’m stumped, and my hosting provider doesn’t provide support for scripting.

Any clues?

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@bokehNov 08.2006 — You are confusing two things: file paths and URLs. In the case of URLs in order for things to work in relation to one another the document and its images must be descendants of a common root directory. In the case of [B]http://domain.com/sub/file.ext[/B] that is the case. The root directory is marked in red.[CODE]/home/username[color=red]/public_html[/color]/sub/file.ext
/home/username[color=red]/public_html[/color]/images/image.jpg[/CODE]
in the case of [B]http://lemon.domain.com/file.ext[/B] things are like this:[CODE]/home/username/public_html[color=red]/lemon[/color]/file.ext
/home/username[color=red]/public_html[/color]/images/image.jpg[/CODE]
In this case the files do not share a common root directory so the only way to get things to work is use a full, absolute URL to call the image file from the document.
Copy linkTweet thisAlerts:
@chestertbauthorNov 08.2006 — So even though, on the server's hard drive, test is a subfolder of public_html, there's still no way I can path to files in that folder, other than by using the url (which won't work because it's the scripts I want to access, not the images.

Hmmm... ah well, back to the drawing board. Thanks Bokeh.
Copy linkTweet thisAlerts:
@bokehNov 08.2006 — So even though, on the server's hard drive, test is a subfolder of public_html, there's still no way I can path to files in that folder, other than by using the url (which won't work because it's the scripts I want to access, not the images.[/QUOTE]Of course you can do it with a file path. What you can't do is use relative URLs in the document.
Copy linkTweet thisAlerts:
@chestertbauthorNov 09.2006 — Ok. I get it.

This works...
[code=php]// get the connection variables
require_once '/home/user/public_html/admin/connect.inc.php';
$user = $connect[0];
$pass = $connect[1];
$db = $connect[2];[/code]

...because it's a file path.

This doesn't...
[code=html]<a href='/home/user/public_html/admin/setup.php'>[/code]
...because it's a url.

So is the no way to path to the setup.php script?
Copy linkTweet thisAlerts:
@TaschenNov 09.2006 — Just to clarify:

A relative URL looks like this [code=html]<a href="../directory/file.html">link</a>[/code]

A fully qualified URL looks like this [code=html]<a href="http://www.domain.tld/directory/file.html">link</a>[/code]

With a fully qualified url the server can resolve the true location of a file. When using subdomains and relative URLs the server can't accurately resolve the file location because the relative URL points to the wrong directory in this example the "htpdocs" root, whereas it should be looking in "htpdocs/subdomaindirectory/":

sub domain url - htt://subdomain.mydomain.tld/file.html

actual file location htt://mydomain.tld/subdomaindirectory/file.html

Hope this helps. I would also counsel against putting this "/home/user/public_html/admin/setup.php" in a link or to locate an image file, rather use a fully qualified URL. You are giving away more than you want to about your server setup.
×

Success!

Help @chestertb spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...