2013-04-03 138 views
2

我遇到了CakePHP的问题,找不到CSS。当我在浏览器中查看源代码时,我可以在头部看到蛋糕通用CSS链接。但是当我点击它看到实际的源代码时,我得到一个404未找到的错误。CSS不能与CakePHP一起使用App

更新: 我在这儿跟着指示:

http://book.cakephp.org/2.0/en/installation/url-rewriting.html

确保mod_rewrite的设置正确,但我仍然无法观赏的CSS文件。

更新: 这是的.htaccess看起来像我的根文件夹:

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^$ app/webroot/ [L] 
    RewriteRule (.*) app/webroot/$1 [L] 
</IfModule> 

这是的.htaccess看起来像我的应用程序文件夹:

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^$ webroot/ [L] 
    RewriteRule (.*) webroot/$1 [L] 
</IfModule> 

,这是在我的webroot文件夹中看起来如何:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php [QSA,L] 
</IfModule> 

Regards, Stephen

+0

该文件的权限是否正确? – Quantastical

+0

该文件位于您认为它在的目录中吗? – DiMono

+0

@MrSlayer是的,他们是正确的。 – Stephen

回答

0

你让CakePHP创建链接到CSS吗?就像这样:

echo $this->Html->css('cake.generic'); 

如果Apache是​​指向根目录,你的CSS是在根目录/ CSS/cake.generic.css,那么你应该能够浏览它在

http://website/css/cake.generic.css 

如果您把CSS文件放入webroot中,你可以浏览它吗?

+0

回答你的第一个问题,是的,我让CakePHP创建链接到CSS文件,如上所示。我无法浏览cake.generic.css我收到没有数据收到错误消息。 – Stephen

+0

你能看到磁盘上的文件(在Finder中),它在哪个目录中?您是否尝试将其移动到webroot并手动链接到它(不使用CakePHP的帮助程序)? – toby1kenobi

+0

@ tobi1kenobi是的,我可以在Finder projectname/app/webroot/css/cake.generic.css中看到该文件。当安装CakePHP时,我不确定将它移动到webroot的意思,这是默认位置文件。 – Stephen

1

我设法解决它。问题是与我建立了我的虚拟主机的方式,我的httpd-vhosts.conf文件现在看起来是这样的:

<VirtualHost *:80> 
    ServerAdmin [email protected] 
    DocumentRoot "/Users/stephenxconnolly/Documents/Websites/invoice-new" 
    ServerName invoice.dev 
    <Directory "/Users/stephenxconnolly/Documents/Websites/invoice-new/"> 
     AllowOverride All 
    </Directory> 
# ServerAlias www.dummy-host.example.com 
    ErrorLog "/private/var/log/apache2/invoice.dev-error_log" 
    CustomLog "/private/var/log/apache2/invoice.dev-access_log" common 
</VirtualHost> 

这解决了这个问题。

相关问题