0

我有一个像这样的结构:

root/
  directory/
    index.php
    includes/
      header.html
    css/
      style.css
    pages/
      somefile.php
      somefile2.php

所有三个文件(index.php、somefile.php 和 somefile2.php)都包含 header.html。header.html 具有到 css 的相对链接。由于我不是 php 专业人士,因此我不知道如何设置此路径以使其适用于所有三个页面。我在某处看到它说我必须定义 php 路径,但这设置为 root/ 而不是 root/directory/ ,如 www.mysite.com/directory/

4

1 回答 1

0

I believe the simplest solution would be to add the following line to your header:

<base href="http://example.com/">

Then all of your relative paths will start from the root directory. The alternative is to update all of your relative paths corresponding to their location in the directory hierarchy. Something like:

$_SERVER['DOCUMENT_ROOT'] . '/dir1/dir2/page.html'

// or...

'../../page.html'
于 2014-04-28T18:10:29.400 回答