我想加载一个JavaScript和CSS文件的链接和脚本标签。该项目使用php命名空间,因此文件正尝试通过设置控制器的路由器脚本加载。也许需要更多的解释。PHP命名空间加载JavaScript文件错误
当访问者第一次来到http://site0
根.htaccess
文件重写到/public
目录与文件/public/.htaccess
一切改写为/public/index.php
文件。 /public/index.php
只是一个spl_autoload
函数,并调用router.class.php
脚本来决定调用哪个控制器类。
的root .htaccess
内容:的public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
#RewriteCond %{REQUEST_URI} \.css$
RewriteRule (styles/[^/]+\.css)$ /$1 [L]
# File is located in /foldername/images/
# Internal redirect. Does not change address in the browsers address bar.
RewriteCond %{REQUEST_URI} \.(gif|jpg|png)$
RewriteRule ^.*(images)/(.*)(\.gif|jpg|png)$ $1/$2$3 [L]
# File is located in /foldername/scripts/.
# Internal redirect. Does not change address in the browsers address bar.
RewriteCond %{REQUEST_URI} \.js$
RewriteRule (scripts/[^/]+\.js)$ /$1 [L]
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
内容:中public/index.php
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
内容:
<?
//set_include_path('PATH_TO_GLOBAL_LIBS; PATH_TO_LIBRARY_1; PATH_TO_LIBRARY_X; PATH_TO_DOCUMENT_ROOT');
define('DS', DIRECTORY_SEPARATOR);
define ('ROOT', dirname(dirname(__FILE__)));
include_once (ROOT . DS . 'inc/dbconf.php');
function multi_autoloader($class)
{
$class = preg_replace('/^((\w*)\\\){2}/', '', $class);
$file = ROOT . DS . str_replace('\\', DS, strtolower($class)) . '.class.php';
if (file_exists($file))
{
require ($file);
}
}
spl_autoload_register('multi_autoloader');
use potts\john\libs\router\Router as Router;
$router = Router::getInstance();
$router->initRouter();
的router.class.php
文件是相当大的,但如果你需要看它, 让我知道。通过console/inspector
我从css和javascript文件中获得状态500
。在一个我不需要使用php namspaces的项目中,所有的工作都很好。所以这必须是由空隙造成的问题。
有关如何解决此问题的任何建议?