img标签无法访问图片。 查看代码如下: -
<?= Html::img(Yii::getAlias('@web').'/web/uploads/'.$model->logo, ['alt'=>'some', 'class'=>'thing']);?>
答案 0 :(得分:2)
删除 / web
<?= Html::img(Yii::getAlias('@web').'/uploads/'.$model->logo, ['alt'=>'some', 'class'=>'thing']);?>
答案 1 :(得分:0)
可以是相对路径
<?= Html::img(Yii::getAlias('@web'). '.'.
DIRECTORY_SEPARATOR . 'uploads' .DIRECTORY_SEPARATOR .$model->logo,
['alt'=>'some', 'class'=>'thing']);?>
答案 2 :(得分:0)
在.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