【发布时间】:2013-02-26 19:42:57
【问题描述】:
我已经从服务器下载了一个 kohana 项目到 localhost ubuntu 系统。我在 var/www/testsite/ 中为它创建了一个文件夹 我已经按照建议更改了 boostrap.php 中的 Kohana::init
Kohana::init(array(
'base_url' => '/testsite/'
, 'index_file' => FALSE
, 'profile' => ! IN_PRODUCTION
, 'caching' => IN_PRODUCTION
));
当我在本地运行站点时,localhost/testsite/ 我看到网站正在加载,但由 css 文件加载的图像没有出现。示例图像的路径是这样的 url("/assets/images/testsite/default/background_all.jpg") 如果我将 url 更改为 url("assets/images/testsite/default/background_all.jpg") 图像会正确显示。
当我点击一个链接时,我会得到
找不到
在此找不到请求的 URL /testsite/contact/info 服务器。 Apache/2.2.22 (Ubuntu) 服务器在 localhost 端口 80
这就是我的 .htaccess 的构造方式,
# Put your installation directory here:
# If your URL is www.example.com/kohana/, use /kohana/
# If your URL is www.example.com/, use /
RewriteBase /testsite/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
为什么它在服务器上运行而不是在我的本地主机上运行? 如何在不更改 css 文件的 url 路径的情况下解决此问题?
谢谢
【问题讨论】:
-
这样写
url("assets/images/testsite/default/background_all.jpg")有什么问题? -
因为在服务器上它的工作方式类似于 url("/assets/images/testsite/default/background_all.jpg") 而不是 url("assets/images/testsite/default/background_all.jpg" )
-
你可以覆盖
url()函数并修复它。 -
我该怎么做?为什么它在服务器上而不是在我的本地主机上工作?有什么区别?