가장 좋은 방법은 상대 경로 또는 절대 경로를 사용할지 여부입니다. 일반적으로 '/'는 파일 시스템의 루트 또는 웹 사이트의 루트에서 절대 경로를 지정합니다. 당신이 선도적 인 슬래시를 포함한 ommitting의 옵션 또는이있을 때
는 자신의 코드에서 mysite.com/files/css/info.css
...
background-image:url('/bg.png'); /* absolute - use mysite.com/bg.png */
background-image:url('bg.png'); /* relative to info.css - use mysite.com/files/css/bg.png */
...
에서 당신을에있는 예제 CSS 파일을 가지고 유사한 규칙을 따를 수 있습니다.
<?php
// $uri - the relative/absolute uri to link to, ie /posts or 'show/id'
// $text - the text link
function link_to($uri, $text) {
if ($uri[0] == '/') {
// assume absolute
$href = $uri;
} else {
// assume relative to current uri; remove last segment and replace
$uri_segments = get_uri_segments();
array_pop($uri_segments);
array_push($uri_segments, $uri);
$href = implode('/', $uri_segments);
}
return "<a href=\"$href\">$text</a>";
}
//
// elsewhere, assuming current URL is 'myself.com/users'
//
// relative link to 'create'
link_to("create", "Show User"); // mysite.com/users/create
// absolute link to '/products'
link_to("/products", "Products"); // mysite.com/products
?>
나는 당신을 이해하는지 잘 모르겠습니다. 파일 경로를 의미합니까? –