try updating your template with the below fragment
{{ HTML::style( asset('css/common.css') ) }}
or manual way
<link href="{{ asset('css/common.css') }}" rel="stylesheet">
The asset()
function is a 'shortcut' for the public folder path.
Question
i'm a laravel newbie, and i'm trying to import a css file into my blade template in the views folder.
I have this in the routes file:
Route::get('/', function()
{
return View::make('index');
});
index.blade.php in the 'views' folder has the following code in the header section:
{{HTML::style('css/common.css');}}
</head>
common.css is a file in public folder, inside a css subfolder.
The index.blade.php view runs without errors, showing up all the html elements, but without the css. What am i missing here? Any help would be much appreciated.
Edit: It looks like the problem has to do with some .htaccess or xampp configuration. The href generated in the page shows [http://localhost/testLaravel/server.php/css/common.css], and that is why it doesn't get the css code. The correct path would be [http://localhost/testLaravel/public/css/common.css].
mod_rewrite is on and my .htacess file is:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Any help getting rid of the server.php portion of the path would be much appretiated.
Solution
try updating your template with the below fragment
{{ HTML::style( asset('css/common.css') ) }}
or manual way
<link href="{{ asset('css/common.css') }}" rel="stylesheet">
The asset()
function is a 'shortcut' for the public folder path.