![](/img/trans.png)
[英]How can I include a class that is in the parent directory using Kohana PHP
[英]How can I make PHP think that the files are in a parent directory?
正如标题所说,如何让 PHP 认为文件在父目录中?
例如,我的文件结构如下所示:
- website
- - css
- - js
- - images
而且我想让 PHP 认为目录js
总是在../js
(父目录)中? 这可以用.htaccess
完成吗?
谢谢。
您可以将此规则放在/website/js/.htaccess
:
RewriteEngine On
RewriteBase /website/js/
RewriteRule ^(.*)$ /js/$1 [L]
您可以将当前目录更改为如下所示:
<?php
// Get current directory
$cur_dir = getcwd();
//change the dir
chdir("../js");
//do something here
//back to your main current dir if you have still something to do
chdir($cur_dir);
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.