0

I'm using Laravel 5.2 and I wanted to give my stylesheet an absolute path

<link rel="stylesheet" href="{{ URL::to('css/styles.css') }}">  

the stylesheet can't be loaded . when i use href="{{ asset('css/styles.css') }}" it works just fine but when i use the facade URL::to() it doesn't load .

Toby Mellor
  • 8,093
  • 8
  • 34
  • 58
R0b0t0
  • 390
  • 6
  • 20

2 Answers2

1

URL::to() will return an absolute path. Do you have index.php in your url? In your example, the only real difference between URL::to() and asset() is that the asset() method will remove any reference to index.php, but URL::to() won't.

If you want to use the URL facade instead of the global helper methods, I would suggest using URL::asset() instead of URL::to(). That is the function specific for loading assets, and is actually what the asset() helper function calls.

patricus
  • 59,488
  • 15
  • 143
  • 145
-1

let's try it will work

do this:
set your url in app/config/app.php

then initiate URL:
URL::forceRootUrl(Config::get('app.url'));

so you will get the URL by:
url('/);
Saravanan Nandhan
  • 579
  • 10
  • 19