0

I am trying to import css file but i just cant.

my css file is in "public/css/style.css"

i ve tried all possible combinations that i found on internet but nothing works

<link href="/css/style.css" rel="stylesheet">
<link href="{!! asset('css/style.css') !!}" media="all" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="{{ URL::asset('css/style.css') }}" />

Laravel .htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

but nothing just works for me

JGeorgeJ
  • 361
  • 7
  • 20

3 Answers3

2
<link href="{!! asset('css/style.css') !!}" media="all" rel="stylesheet" type="text/css" />

Change That to This

<link href="{{ asset('css/style.css') }}" media="all" rel="stylesheet" type="text/css" />

and it should work.

Mahbod_SN
  • 51
  • 1
  • 5
  • If this doesn't work, then make sure that you have properly set up your `.htaccess` (for apache) or your nginx config. – Namoshek Apr 28 '18 at 20:35
  • No it doesnt work and this is my laravel .htaccess. How can i check if my .htacces is set properly. – JGeorgeJ Apr 29 '18 at 05:17
  • https://stackoverflow.com/questions/40682748/assets-not-referencing-to-public-folder-laravel this wont work too – JGeorgeJ Apr 29 '18 at 05:34
1

Solved

i ma probably missing some configuration that i cant find out. But i create virtual host with xampp and set DocumentRoot "C:\xampp\htdocs\final\public" and this works.

Thanks for help guys.

JGeorgeJ
  • 361
  • 7
  • 20
0

Try:

<link href="./public/css/style.css" rel="stylesheet">

The ./ part is the current folder you are in.

  • it does not work. this http://localhost:8000/public/css/style.css and this http://localhost:8000/css/style.css shows up 404 error – JGeorgeJ Apr 28 '18 at 17:59
  • How about mix.less('resources/assets/less/app.less', 'public/css');? Found it on https://laravel.com/docs/5.6/mix#working-with-stylesheets. – matthunterking Apr 28 '18 at 18:13