开发者

Is using /file.php in an anchor link ALWAYS going to resolve to http://thedomain.com/file.php?

from my testing, this is true, but i just want to make sure it is a standard and not just coincidence that all browsers ive tested it in it works

basically, i have a page on

 http://domain.com/sub/dirs/1/2/3/page.htm
开发者_开发问答

which has

<a href="/home.php">

will that always link to

http://domain.com/home.php 

?

and of course will linking to /sub/dirs/1/2/3/page.htm link to itself (ie, link to http://domain.com/sub/dirs/1/2/3.htm) ??

thanks


Yes, that's correct. The leading / means that the link is relative to the top level domain name. Without a leading /, the link is relative to the same directory level as the page where the link appears.

RFC 2396 (Uniform Resource Identifiers (URI): Generic Syntax) contains the following in section 5:

A relative reference beginning with a single slash character is termed an absolute-path reference, as defined by <abs_path> in Section 3.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜