Yii2 고급 템플릿으로 웹 사이트를 만들었으며 "루트"폴더에있는 업로드 폴더의 파일에 액세스하려고합니다. 내가 가진 :Yii2 "루트"폴더에있는 폴더에 액세스하는 방법은 무엇입니까?
backend/web/
frontend/web/
uploads/
내가 그래서 내 htaccess로는 Yii2. Access to higher level folder
의 첫 번째 대답을 따랐다
Options +FollowSymlinks
RewriteEngine On
# deal with backend first
RewriteCond %{REQUEST_URI} /(backend)
RewriteRule ^backend/assets/(.*)$ backend/web/assets/$1 [L]
RewriteRule ^backend/css/(.*)$ backend/web/css/$1 [L]
RewriteRule ^backend/image/(.*)$ backend/web/image/$1 [L]
RewriteCond %{REQUEST_URI} !/backend/web/(assets|css|image)/
RewriteCond %{REQUEST_URI} /(backend)
RewriteRule ^.*$ backend/web/index.php [L]
RewriteCond %{REQUEST_URI} /(assets|css|js|img|font)
RewriteRule ^assets/(.*)$ frontend/web/assets/$1 [L]
RewriteRule ^css/(.*)$ frontend/web/css/$1 [L]
RewriteRule ^js/(.*)$ frontend/web/js/$1 [L]
RewriteRule ^img/(.*)$ frontend/web/img/$1 [L]
RewriteCond %{REQUEST_URI} !/(frontend|backend)/web/(assets|css|js|img|font)/
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ frontend/web/index.php
내 일반/컴포넌트/Request.php 파일
<?php
namespace common\components;
class Request extends \yii\web\Request
{
public $web;
public $adminUrl;
public function getBaseUrl(){
return str_replace($this->web, "", parent::getBaseUrl()) .$this->adminUrl;
}
public function resolvePathInfo(){
if($this->getUrl() === $this->adminUrl){
return "";
}else{
return parent::resolvePathInfo();
}
}
}
?>
입니다
내 앞면/config/main.php
,451,515,..
'components' => [
'request' => [
'cookieValidationKey' => 'xxxxxxxxxxxxxxxxx',
'csrfParam' => '_csrf-frontend',
'class' => 'common\components\Request',
'web'=> '/frontend/web'
],
지금은
Html::img('../..'/uploads/my-image.png')
내 업로드 폴더에있는 이미지를 볼 수 있기 전에 나는 (//프론트 엔드/웹하지 않고) 로컬 호스트/MyApp를 내 사이트에
에 액세스 할 수 그러나 않습니다 ../../uploads 업로드 할 수 없음/
어떻게 업로드 폴더에 액세스 할 수 있습니까? 가상 호스트 구성에서
답장을 보내 주셔서 감사합니다. 하지만 내 서버가 Plesk에 의해 관리되고 SSH 액세스 권한이 없기 때문에 가상 호스트 구성을 수정할 수 없습니다. 다른 해결책이 있습니까? – Ludo