我正在学习 PHP 中的 MVC。 css 和 js 文件在 php 页面中不起作用。
我正在使用 eclipse,xampp 服务器。
这是我的.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME)} !-d
RewriteCond %{REQUEST_FILENAME)} !-f
RewriteCond %{REQUEST_FILENAME)} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
这是我的 bootstap.php
<?php
class Bootstap {
function __construct() {
$url = isset($_GET ['url'])?$_GET ['url']:null;
$url = rtrim($url,'/');
$url = explode ( '/', $url );
// print_r ( $url );
if (empty($url[0])){
require 'controllers/Index.php';
$controller = new Index();
return false;
}
$file = 'controllers/' . $url [0] . '.php';
//print_r ( $file );
if (! file_exists ( $file )) {
require 'controllers/Error.php';
$controller = new Error ();
return false;
}
require "$file";
$controller = new $url [0] ();
if (isset ( $url [1] )) {
if (isset ( $url [2] ))
$controller->$url [1] ( $url [2] );
else
$controller->$url [1] ();
}
}
}
我该如何解决这个问题?
最佳答案
RewriteEngine On
RewriteBase /clients
RewriteRule ^(css|images|scripts|js|png|jpg) - [QSA,L]
关于javascript - css 和 js 文件在 php 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29225800/