2013-04-03 133 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> 

這解決了這個問題。

相關問題