[英]css & js file not working in php
我正在用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]
如果您對css,img ...的重寫不正確,則根據您的規則將此行添加到htaccess文件中
RewriteRule ^(css|images|scripts|js|png|jpg) - [L]
您包括CSS / JS文件的位置?
據我所知,它與.htaccess
和MVC
沒有任何關系,在MVC
,您的基本css/js files
以正常方式包含,例如我們如何包含在core PHP
(帶有html start head標簽等)。
我建議在這里在瀏覽器中運行您的頁面,並檢查視圖源。 您必須在源代碼中找到css / js pahts,問題可以在此處查找錯誤的路徑(包括未針對公共文件精確設置的位置),您只需更正並設置正確的完整路徑即可解決該問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.