【发布时间】:2021-02-08 15:22:04
【问题描述】:
我在 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>
【问题讨论】:
-
您在项目的根目录中引用了
.htaccess文件吗?尝试将您的APP_URL设置为http://localhost:8082。
标签: css laravel url-rewriting