2017-05-23 15 views
1

서버 측 포함을 사용하여 파일을 구성했습니다.서버 측에 중첩 호출을 할 수 없습니다.

중첩 된 파일이 작동하지 않는 것 같습니다. 예를 들어 : -

index.shtml -이

<!doctype html> 
<html lang="en"> 
    <!--#include virtual="partials/head.shtml"--> 
<body> 
<!--#include virtual="partials/components/ads/horizontal-banner.shtml"--> 
<div id="site-wrapper"> 
    <header id="site-header"> 
     <!--#include virtual="partials/header.shtml"--> 
    </header> 

    <div id="site-body"> 
     <!--#include virtual="partials/pages/home.shtml"--> 
    </div> 

    <footer id="site-footer"> 
     <!--#include virtual="partials/footer.shtml"--> 
    </footer> 
</div> 
<!--#include virtual="partials/common.shtml"--> 

home.shtml 내부에 잘 작동은되고 다음 다른 통화

<!--#include virtual="../components/newsletter.shtml"--> 

있다 프로젝트 구조 : -

아파치의 설명서에서3210
project 
- css 
- assets 
- js 
- partials 
    - components 
     - ads 
     horizontal-banner.shtml 
     vertical-banner.shtml 
     newsletter.shtml 
     help.shtml 
    - pages 
     home.shtml 
     about.shtml 
    header.shtml 
    footer.shtml 
    head.shtml 
    common.shtml 
index.shtml 

답변

0

봐 - Server Side Includes :

는 헤더 및/또는 이러한 업데이트의 부담을 줄일 수 있습니다 바닥 글에 대한 파일을 포함하여. 하나의 꼬리말 파일을 작성하면 이 include SSI 명령으로 각 페이지에 포함됩니다. include 함수는 파일 특성 또는 가상 특성과 함께 포함 할 파일을 결정할 수 있습니다. file 속성은 현재 디렉토리에 상대적인 파일 경로입니다. 즉, 은 절대 파일 경로 (/로 시작)가 될 수 없으며 ../에는 해당 경로의 부분 인 을 포함 할 수 없습니다. 가상 속성이 더 유용 할 수 있으며 은 제공되는 문서에 상대적인 URL을 지정해야합니다. 은 /로 시작하지만 인 파일과 동일한 서버에 있어야합니다. ..

<!--#include virtual="partials/components/newsletter.shtml"--> 

을하고 newsletter.shtml 파일은 유사한 방식으로 변경해야합니다 :

시도는이 같은 home.shtml을 변경합니다.

+0

xampp 안에 htdocs 내부에 폴더를 배치했을 때 작동했습니다. 일반 디렉토리에 배치하면 작동하지 않습니다. 왜 그런지 모르겠다 .... –

+0

아파치의 액세스 및 오류 로그 파일을 보려고 했습니까? 위치가 문제가 있으면 잘못된 경로에 대한 정보가 있어야합니다. –