【发布时间】:2018-01-14 22:34:00
【问题描述】:
在服务器(共享主机)上,public 文件夹内的所有资产都不会显示。即
<img src="{{asset($painting->file)}}" >
输出这个
<img src="http://subdir.example.com/uploads/awJ4o8_miro1.jpg" >
它应该有一个 public 文件夹
http://subdir.example.com/public/uploads/awJ4o8_miro1.jpg
在我的 Public_html 文件夹中,我有这个文件夹结构
PUBLIC_HTML
├───app
├───bootstrap
├───cgi-bin
├───config
├───database
├───public
│ ├───css
│ ├───img
│ ├───js
│ ├───uploads
│ └───videos
│ .htaccess(file)
│ .index.php(file)
├───resources
├───storage
└───tests
└ .htaccess(file)
两个.htaccess文件都是这样的文件
DirectoryIndex public/index.php
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
</IfModule>
权限
所以我的问题是如何设置我的配置 (.htaccess) 以便我可以在共享托管站点上显示我的资产。
【问题讨论】:
-
生成的url是正确的,你的
public文件夹是你的文件根目录,不应该包含在url中。您是否使用/public访问您的网站? -
嗨@Jeredov。不,我没有使用
/publi/访问我的网页,但如果我更改 url 并将 public 添加到其中,一切正常http://miro.mongexweb.ca/public/uploads/NUsZlC__MG_5032.jpg
标签: laravel .htaccess laravel-5.1 shared-hosting laravel-storage