Perhaps the return value of base_url() does not end with a path separator.
With this in mind, try the following:
@import url("<?php echo base_url().'/public/';?>css/layout.css");
(Note the slash before "public")
- Check the source of the page through your browser "source of view" or similar, and check the path in
@import
or
- Use a query logger similar to the Chrome network devtools "network network" tab to find out which URL is trying to load your imported CSS file from your browser.
You also look at CSS through your browser to determine if the content is built correctly. If you see <?php inside the answer, you need to force Apache to treat the CSS file as if it were PHP.
You can add something like the following to your .htaccess file:
<FilesMatch "\.css$"> SetHandler application/x-httpd-php Header set Content-type "text/css" </FilesMatch>
You must ensure that the Apache module "mod_headers" is enabled to enable the use of the Header directive.
Although, personally, I would rename such dynamic stylesheets to have the extension .php.css. This will have no effect, but then Apache can only be configured to pass dynamic stylesheets to the PHP preprocessor.
<FilesMatch "\.php\.css$"> SetHandler application/x-httpd-php Header set Content-type "text/css" </FilesMatch>
Spooky
source share