Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CakePHP doesn't output correct path to CSS

Just started developing in CakePHP, installed it and configured it. However the application doesn't output the correct path to the stylesheet.

When viewing the source of the page the path to the stylesheet is:

/rm-lab/css/cake.generic.css

This leads to 404 error page.

The stylesheet loads if I try to access it through this path;

/rm-lab/app/css/cake.generic.css

Appreciate the help.

UPDATE: After trying numerous solutions, I just did a fresh install of cakePHP in another subfolder and this loads the CSS fine. I think it was to do with the .htaccess files.

like image 760
Mr B Avatar asked Jul 27 '26 21:07

Mr B


1 Answers

It appears that your cake app is in a subfolder. You should set the rewrite base in your .htaccess file in app/webroot

In app/webroot/.htaccess, add the following line:

RewriteBase /rm-lab

Your .htaccess file should now appear as such:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /rm-lab
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
like image 186
Wil Avatar answered Jul 29 '26 11:07

Wil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!