圖像無法在img標記中訪問。 查看代碼如下: -yii2圖像路徑在img標記中給出404錯誤
<?= Html::img(Yii::getAlias('@web').'/web/uploads/'.$model->logo, ['alt'=>'some', 'class'=>'thing']);?>
圖像無法在img標記中訪問。 查看代碼如下: -yii2圖像路徑在img標記中給出404錯誤
<?= Html::img(Yii::getAlias('@web').'/web/uploads/'.$model->logo, ['alt'=>'some', 'class'=>'thing']);?>
取得了.htaccess文件的一些變化和問題解決了。
Options +FollowSymlinks
RewriteEngine On
# deal with admin first
RewriteCond %{REQUEST_URI} ^/advanced/(admin)
RewriteRule ^admin/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^admin/css/(.*)$ backend/web/css/$1 [L]
RewriteRule ^admin/uploads/(.*)$ backend/web/uploads/$1 [L]
RewriteCond %{REQUEST_URI} !^/advanced/backend/web/(assets|css|uploads)/
RewriteCond %{REQUEST_URI} ^/advanced/(admin)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} ^/advanced/(assets|css)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteCond %{REQUEST_URI} !^/advanced/(frontend|backend)/web/(assets|css|uploads)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
刪除/網絡
<?= Html::img(Yii::getAlias('@web').'/uploads/'.$model->logo, ['alt'=>'some', 'class'=>'thing']);?>
可能是相對路徑
<?= Html::img(Yii::getAlias('@web'). '.'.
DIRECTORY_SEPARATOR . 'uploads' .DIRECTORY_SEPARATOR .$model->logo,
['alt'=>'some', 'class'=>'thing']);?>
不工作,仍然給404 –
你上傳你的文件? –
以及如何從服務器訪問您的後端,在後端/ web/uploads /中使用yii serve或http:// localhost/project/backend/web –