Jump to content
xisto Community
Sign in to follow this  
jlhaslip

Server Absolute Referencing on a trap17 sub-domain

Recommended Posts

When referencing a file or pix inside an html file, there are absolute references, relative references and server absolute references. I think I am okay with the first two kinds, but have a question about server absolute.

Assume I have a subdomain of the Xisto named subdomain.
In the subdomain, I have a public_html folder which contains the files accessible from the web, so if in one of those files, lets say it is located in a folder named folder1 and is inside the public-html, I insert a "server absolute reference", does the reference begin at the public_html folder?.

Location of file: public_html/folder1/file1for a server absolute reference: /folder1/file1

Is this correct? Or does the referencing begin above the public_html folder?

Notice from jlhaslip:
Edit to insert bbcode

Edited by jlhaslip (see edit history)

Share this post


Link to post
Share on other sites

The DocumentRoot directory is where all public content is served from. On a correctly configured, secure and reliable server (such as Apache), it is impossible to access anything at or above the level of that directory. Referencing '/public_html/file' for client-side usage will result in the sever attempting to serve '/your/home/path/public_html/public_html/file', if that makes sense.

 

When using server-side languages, however - such as PHP - you have to remember that the paths are relative to the server, not the DocumentRoot directory, so '/file' is literally '/file' in the root directory of the current hard disk. When internally referencing other files within a script (such as via PHP's include() or require() functions), you should always prefix it with $_SERVER['DOCUMENT_ROOT'] so as to ensure the correct file is being accessed.

Share this post


Link to post
Share on other sites

When internally referencing other files within a script (such as via PHP's include() or require() functions), you should always prefix it with $_SERVER['DOCUMENT_ROOT'] so as to ensure the correct file is being accessed.

Which is what I just said. It should be pointed out, however, that using $_SERVER['DOCUMENT_ROOT'] is not a reliable method when running PHP on IIS.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.