我在www.mydomain.com/test上的Godaddy子域安装了CI 我的主页加载以及指向我/新闻页面的链接
我遇到的问题是我无法加载任何图像或加载我的CSS文件。我通过以下方式从头文件中调用我的CSS:
<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>inc/css/base.css" media="all"/>
我通过以下方式调用我的标题图片:
<img src="images/logo.png">
当我右键单击X应该是的位置时,在新标签中选择打开,这样我就可以看到它指向的URL ...看起来不错。 http://mydomain.com/test/images/logo.png
我回应了我的site_url和base_url,他们似乎正确指向: http://www.mydomain.com/test/
我的结构是: / test
1 index.php
2 .htaccess
3 / system
4 / application
在查看了stackoverflow问题之后......我将我的.htaccess粘贴到我的www.mydomain.com/test文件夹中,其中CI为:
RewriteEngine On
RewriteBase /test
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /test/index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
我的config.php是:
$ config ['base_url'] ='http://www.mydomain.com/test/';
$ config ['index_page'] =“”;
$ config ['uri_protocol'] =“自动”;
答案 0 :(得分:1)
我对您的代码做了一些小改动。
<link rel="stylesheet" type="text/css" href="<?php echo base_url('inc/css/base.css'); ?>" media="all"/>
概念:base_url()
返回您的站点基本URL,如配置文件中所指定。例如:
echo base_url();
此函数返回与site_url
相同的内容,不附加index_page或url_suffix。
也像site_url
一样,您可以将字符串或数组提供。这是一个字符串示例:
echo base_url("blog/post/123");
上面的示例将返回类似于:
的内容
http://example.com/blog/post/123
有关详细信息,请阅读CodeIgniter网站上的URL帮助程序指南:URL Helper Guide