php - Laravel 公共内容无法在共享主机上访问
问题描述
我正在使用带有 php 7.4 和 Laravel 的共享主机。我在根 www/ 文件夹中创建了项目,然后我需要添加一个 htaccess 文件来加载 index.php
source file: www/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^ /public/index.php [L]
</IfModule>
它允许我加载网站,但从那时起我无法加载公共内容。运行本地服务器我可以加载样式表等公共资源
<link rel="stylesheet" href="{{ URL::asset('css/main.css')}}">
但在生产环境中,它在生成的源上返回 404
<link rel="stylesheet" href="http://neovita.web277.uni5.net/css/main.css">
解决方案
在.htaccess
添加这个
RewriteEngine On
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
推荐阅读
- asp.net-core - IIS swagger 上的 Blazor 重定向
- c# - 如何将 SOAP UI 中的 SOAP 测试转换为 C#?
- javascript - 如何将带有静态文件引用的 HTML 代码注入 Django 模板
- google-chrome - 浏览器上的错误消息
- tensorflow - 翻转 TF 数据集的标签
- ssis - 带有 ORDER BY 的 ODBC 数据流源
- ios - Flutter iOS 自动填充强密码错误
- scale - 使用雪花的最大数据仓库规模
- amazon-s3 - 以编程方式访问新 (KMS-CMK) 加密的 S3 对象
- sharepoint - 在 SharePoint 中创建新的 Web 应用程序时,我可以在应用程序池名称中添加空格吗?