CSS在我的CodeIgniter项目中不起作用,但为什么呢?

时间:2015-04-23 03:30:51

标签: css .htaccess codeigniter-2 codeigniter-url

My Project Directory at Server address is : ci.xyz.com/ci/h/

I used on my codeigniter project:

$config['base_url'] = './';
$config['index_page'] = '';//index.php

路线为:

$route['default_controller'] = "home/index/";

htaccess的

<IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /ci/h/
 RewriteCond %{REQUEST_URI} ^system.*
 RewriteRule ^(.*)$ /index.php?/$1 [L]
 RewriteCond %{REQUEST_URI} ^application.*
 RewriteRule ^(.*)$ /index.php?/$1 [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>
   ErrorDocument 404 /index.php
</IfModule>  

当加载home(来自路由默认控制器)的索引功能时,所有资源都在工作。但是,当我点击链接(例如home / aboutus)时,资源不能仅显示文本。我用作链接echo base_url(&#39; home / aboutus&#39;);并为resoureces echo base_url(&#39; assets / theme / css / style.css&#39;);

我错了什么?你能告诉我一下我的问题吗?

1 个答案:

答案 0 :(得分:1)

我建议使用子域名,例如http://ci.xyz.com 设置$ route ['default_controller'] =“home / index /”;到 $ route ['default_controller'] =“home”;

打开application / config / config.php并将你的base_url设置为 $ config ['base_url'] ='http://ci.xyz.com/'; //不要忘记最后的正斜杠 然后将您的ROOT / .htaccess更改为

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>

要链接到ROOT / assets文件夹中的CSS文件,只需使用资产/主题/ css / style.css

等内容