我已经搜索了并尝试了许多解决方案,为别人工作,但不是在我的情况。我不知道为什么。为什么CSS和JS没有加载?
背景:
我正在学习用笨2.2.0。我已经建立了项目结构和所有的东西,但我仍然无法加载我的CSS和JS。
查看代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<title> </title>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<!-- solution 1 I have tried: -->
<!-- in below line I tried by using constant set in constants.php file under application/config/ folder -->
<link rel="stylesheet" href="<?php echo (CSS.'dialog.css');?>" type="text/css">
<!-- solution 2 I have tried: -->
<!-- As my css n script files are under CodeIgniter_2.2.0/assets/css and CodeIgniter_2.2.0/assets/scripts folder respectively -->
<link rel="stylesheet" href="/assets/css/dialog.css" type="text/css">
<!-- solution 3 I have tried -->
<!-- This I tried by using autoload.php settings where I am setting autoload['helper'] = array('url'); -->
<?php echo link_tag('assets/css/dailog.css');?> </br>
<script src="../../script/Plugins/jquery.js" type="text/javascript"></script>
</head>
</html>
配置:
而且我已经在application/config/config.php
文件中设置
$config['base_url'] = "http://localhost/";
。
项目文件夹结构:
我的项目文件夹结构如下:
(应用程序,系统,资产文件夹是在同一级别)
的内容.htaccess
文件是:
(.htaccess文件路径:C:\ XAMPP \ htdocs.htaccess)
RewriteEngine on
RewriteCond $1 !^(index\.php|images|js|css|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
有在C:\xampp\htdocs\CodeIgniter_2.2.0\System
2更.htaccess
文件和文件夹C:\xampp\htdocs\CodeIgniter_2.2.0\application
既 有单行写入:
Deny from all
此外,在C:\xampp\htdocs\
,有一个文件index.php
,它与index.php
文件放置在 C:\xampp\htdocs\CodeIgniter_2.2.0\
相同,其中我已设置以下东西
$system_path = 'CodeIgniter_2.2.0/system';
$application_folder = 'CodeIgniter_2.2.0/application';
有什么,我在这里失踪?我无法在我的页面上加载任何CSS或JS文件。
这可能是相关的一个实例您的CSS文件被命名为'对话框,然后其他两个实例是'dailog'?这应该是相同的文件,或者你有多个CSS文件吗? – TylerH 2014-10-16 17:39:41
我已经回答了一个可能对您有用的问题:http://stackoverflow.com/questions/19201362/codeigniter-unable-to-access-the-stylesheets/19204480#19204480 – grim 2014-10-18 16:46:18
您在浏览器中收到什么信息为你正在加载的文件? 404?你也可以展示你在HTML中返回的三个尝试解决方案吗? – grim 2014-10-18 16:48:32