为什么从" public"更改目录名时链接不起作用?到" public_html"我在代码中更改了目录的名称及其下方。当我将所有内容更改回" public"时,它再次起作用。我需要改为" public_html"因为这是我托管的主要文件夹
<?php
define("PRIVATE_PATH", dirname(__FILE__));
define("PROJECT_PATH", dirname(PRIVATE_PATH));
define("PUBLIC_PATH", PROJECT_PATH . '/public_html');
define("SHARED_PATH", PRIVATE_PATH . '/shared');
$public_end = strpos($_SERVER['SCRIPT_NAME'], '/public_html') + 7;
$doc_root = substr($_SERVER['SCRIPT_NAME'], 0, $public_end);
define("WWW_ROOT", $doc_root);
require_once('functions.php');
?>
的functions.php
<?php
function url_for($script_path) {
if($script_path[0] != '/') {
$script_path = "/" . $script_path;
}
return WWW_ROOT . $script_path;
}
?>
其中一个链接的示例
<a href="<?php echo url_for('/home/index.php'); ?>">Home</a>