CakePHP does not output the correct CSS path

Just started developing in CakePHP, installed it and configured it. However, the application does not display the correct path to the stylesheet.

When viewing the page source, the path to the stylesheet:

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

This results in a 404 error page.

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

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

Rate the help.

UPDATE: Having tried numerous solutions, I just made a new cakePHP installation in a different subfolder, and this loads the CSS. I think this is due to .htaccess files.

+3
source share
6 answers

It looks like your cake app is in a subfolder. You must set the rewrite base in the .htaccess file in app / webroot

app/webroot/.htaccess :

RewriteBase /rm-lab

.htaccess :

<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>
+2

Apache. DocumentRoot Apache /app? . , , Apache Cake ( .htaccess ). , CakePHP mod_rewrite core.php.

0

script public_html "test_rewrite.php" , , mod_rewrite . , , .

<?php
if (in_array("mod_rewrite", apache_get_modules())) {
    echo "mod_rewrite loaded";
} else {
    echo "mod_rewrite not loaded";
}
?>
0

, HtmlHelper::css , . :

( $) - CSS , CSS. $path - '/', - . CSS-, Webroot/CSS.

cake.generic.css app/webroot/css, $this->Html->css('cake.generic'), .

API: HtmlHelper

0

, apache DocumentRoot /path/to/your/site/in/a/subdir/webroot

Part of the website is crucial - it prohibits access to files from outside webroot and htaccess in the webroot folder, skips uploading the index.php file for sending actual files inside webroot (img, css, etc.)

If you have the DocumentRoot path set correctly, and the subfolder from the site’s root directory to install the cake is included in the .htaccess file, as mentioned above, the fix problem should fix itself.

You might want to tell us the absolute path on the server to the installation for the cake, and also show us the VirtualHost block with detailed DocumentRoot information.

0
source

All Articles