Laravel链接href无效路径

罗伯特

我在Laravel有网站。.env文件中我设置:

APP_URL=http://localhost:8082/mydomain/public

我在Windows上使用XAMPP。我的.htaccess

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

    RewriteEngine On

    RewriteCond %{REQUEST_URI} !^/public/
    RewriteRule ^(.*)$ public/$1 [L,QSA]
</IfModule>

当我在浏览器中加载主网站时,出现如下错误:

 http://localhost:8082/js/app.js net::ERR_ABORTED 404 (Not Found)

它无法加载任何js或CSS,因为正确的路径应为:

 http://localhost:8082/mydomain/public/js/app.js net::ERR_ABORTED 404 (Not Found)

在文件中的php链接看起来像:

<script src="/js/app.js"></script>
@yield('script')
</body>
</html>
曼尼斯(Manish Rajora)
try this code put it in your app/Helpers/helper.php

function asset($path, $secure = null){
    return app('url')->asset("public/" . $path, $secure);
}

and access resource like eg

 <link rel="stylesheet" type="text/css" href="{{ asset('FOLDER_NAME/css/FILENAEM_EXTENSION') }}">

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章