The structure of my project folder is as follows:
. └── /home (Inaccessible) └── user └── public_html ├── app ┊ ├── public │ ├── css │ ┊ │ └── upload ┊ ├── .htaccess └── .env
As you can see, the project upload folder is in the public folder, and the following code shows the specifications of my public disk:
'disks' => [
'public' => [
'driver' => 'local',
'root' => public_path('upload'),
'url' => env('APP_URL').'/upload',
'visibility' => 'public',
],
]
And because my project is on a shared host, I added an .htaccess file with the following content to public_html:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
And in the .env file I added the following line
ASSET_URL=/public
Now I want to move the upload folder out of public_html, I want the structure of the project folders to be as follows:
. └── /home (Inaccessible) └── user ├── public_html └── upload
I did not get the answer by changing the root address of the public disk as follows, and when I try to display a photo, I get 404 error
.
'root' => preg_replace("/^(.*\/).*$/", "$1" ,$_SERVER['DOCUMENT_ROOT']).'/upload'
// OR
'root' => base_path('../upload')
//OR
'root' => dirname(__DIR__,2) . '/upload',
Is this possible?
UPDATE
The links to my files are like http://example.com/upload/1611343402_Colors.png