I created a site with an extended Yii2 template, and I want to access the files in the download folder located in the root folder. I have:
backend/web/
frontend/web/
uploads/
I followed the 1st answer of Yii2. Access to a higher level folder
So my .htaccess
Options +FollowSymlinks
RewriteEngine On
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
My common / component / Request.php file
<?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();
}
}
}
?>
My front /config/main.php
..
'components' => [
'request' => [
'cookieValidationKey' => 'xxxxxxxxxxxxxxxxx',
'csrfParam' => '_csrf-frontend',
'class' => 'common\components\Request',
'web'=> '/frontend/web'
],
Now I can access my site using localhost / myapp (without / frontend / web /)
Before I could see the image in the download folder using
Html::img('../..'/uploads/my-image.png')
But it no longer works, neither with .. /../uploads, nor with downloads /
How can I access uploads folder?