Page 1 of 1

Relative URLs question

Posted: Sat May 24, 2008 5:36 pm
by hora
Hi everyone,

I did a search for this here and on google and still couldn't find what I was looking for, and hopefully someone here can help me.

In PHP, how do you specify a relative URL that goes to the 'root' directory of your site?

I know that in HTML, if you were here: "www.mysite.com/images/index.html"

and in there you had a link that looked like this: "/files/file.html", it would go to "www.mysite.com/files/file.html"

How do you do this in PHP?

Thanks!

Re: Relative URLs question

Posted: Sat May 24, 2008 11:23 pm
by LSJason
It's done the same way if you are linking. However, if you are using it in the context of a PHP function (include(), require(), etc.), the leading slash ("/") refers to the root of the file system, not the URL. To form a relative file system URL, you would replace the leading slash with ./