0

我正在制作自己的框架,并希望能够轻松地直接访问资产文件,例如图像、javascript 或 css 文件。

目前我正在尝试允许使用

<link rel="stylesheet" href="/assets/css/style.css" />

我有我的 .htaccess 文件捕获 URI 并允许我使用 PHP 操作它。

我的路由器类捕获 uri 并检测文件的实际路径。所以我的问题是我如何用 PHP 编写它?

public function router($file)
{
    //output assets file here
}
4

1 回答 1

0
public function router($file) {
    // Only do this if the file is a valid type to be outputted;
    // It would be bad if someone started viewing your PHP.
    if (file_exists($file)) {
        readfile($file);
    }
}
于 2012-04-09T19:41:18.350 回答