How to reference static files in templates in laravel 5.2?
PHP中文网
PHP中文网 2017-05-16 16:52:47
0
2
470

My demo.css is placed in public/css/demo.css

<link rel="stylesheet" href="{{asset('css/demo.css')}}">

If you quote like this, 404 will appear if you enter directly from the server.php entry. It is found that the generated link is:

..../server.php/css/demo.css

If accessed from public/index.php this is correct, the generated link is:

..../public/css/demo.css

How do you reference your static files? ? ?
Which entrance is generally used to access the website? ? ?

By the way, my server environment is: wampServer

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
巴扎黑

The laravel service root directory is public, so you need to put the css file public/css中,然后再用asset()辅助函数。
我一般是在resource文件夹中放置静态文件,然后通过gulpcopy()into the directory corresponding to public

PHPzhong

You can copy the .htaccess file under public to the project root directory, and then change server.php to index.php to access it. To introduce css files and js files, use {{asset('path') }}.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!