Laravel link href 无效路径

Laravel link href invalid path

我在 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/ [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 中的文件中 link 看起来像:

<script src="/js/app.js"></script>
@yield('script')
</body>
</html>
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') }}">