Hekmatyar's avatar

403 Forbidden Access to this resource on the server is denied!

Project is on subdomain.

permisions is 755 for public_html, project etc

.htacccess from project

Options -MultiViews -Indexes
RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

i updated index.php with currect dir

0 likes
18 replies
Hekmatyar's avatar

i changed path/dir in index with my project folder i allready have 403 or 500 erorr. its direct admin (shared host) laravel 7. this tut noting help..

Hekmatyar's avatar

this is worst of deploying when i was ever see. im trying 30 methods to do this and nothing works. fking great. gg laravel

Snapey's avatar

How can we help if you don't describe what you are trying to do?

Deployment on subdomain is easy, but it depends where you put your code and what your document root is.

The fact that you say "permissions for public_html" tells me you are already going to struggle since Laravel expects your public folder to be public

You can work around this, but the answer is not to just throw everything into public_html

1 like
Snapey's avatar

You are trying to install in a folder, not a subdomain ?

Hekmatyar's avatar

I try everything to make it work. on subdomaind and main domain. to on purpose i wish it was in subdomain.. for now..

im allready do everything from that link and i have 500

Hekmatyar's avatar

Ok, i will start from beginning with fresh files

My laravel project (subdomain <- its name folder) is in root folder. i took content from "public" folder and move to public_html/subdomain

public_html/subdomain/index.php

require __DIR__.'/vendor/autoload.php';
$app = require_once __DIR__.'/bootstrap/app.php';

i changed to:

require __DIR__.'/../../subdomain/vendor/autoload.php';
$app = require_once __DIR__.'/../../subdomain/bootstrap/app.php';

next what i changed is: root/subdomain/server.php

if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
    return false;
}

require_once __DIR__.'/public/index.php';

To:

if ($uri !== '/' && file_exists(__DIR__.'/../public_html/subdomain'.$uri)) {
    return false;
}

require_once __DIR__.'/../public_html/subdomain/index.php';

.htaccess from public_html/subdomain

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    </IfModule>

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

aaand 500

Snapey's avatar

You need to make sure that the storage folder in the subdomain folder is writable

If it is, then you should see a log file being created with the 500 error which will tell you the next step

Hekmatyar's avatar

all 4 folders are writable(755). https://i.imgur.com/hQrZYkU.png project is on laravel 7 and php 7.4

log say: "Auto Index is disabled for [/home/srv*****/domains/maindomain/private_html/subdomain/], access denied" but this log is from 1h ago

Snapey's avatar

Auto index is when you try to access a folder that has no default page and no .htaccess

Hekmatyar's avatar

i have it in subdomain folder (index.php and htaccess). you can see it in picture from my previus post. I think this is not log from now and there is no log of this. apache didn't notice errors from one hours ago to now

Snapey's avatar

Your screenshot is incorrect

You should have the Laravel project installed in a folder alongside the public_html folder

You should have the content of the public folder in a subdirectory of public_html

Therefore storage & bootstrap should not be in the same folder as index.php and .htaccess

Hekmatyar's avatar

Ok, then it is incorrect what ppl say to move project folder to root folder. the correct way is to move project to domain folder alongside the public_html. Mhhhhhm, now i dont have 500 but i still have errors

ErrorException
file_put_contents(G:\XAMP\htdocs\myproject\storage\framework/sessions/TlbntA0pnA6qgMDHNnSTvu9fqSLUdWc6pUmcWW77): failed to open stream: No such file or directory

up -> maindomain/project/bootstrap/cache i changed name of config.php and page is work but storage etc nope

my contect from public still is in subdirectory how was earlier /domains/maindomain/public_html/subdomain

where should by storage&bootstrap?

Hekmatyar's avatar

No link to data storage location. A symbolic link to the data storage location could not be found. This can cause problems loading media files in the browser.

ErrorException symlink(): No such file or directory

Hekmatyar's avatar

i removed storage and i use "php artisan storage:link" but still i have "ErrorException symlink(): No such file or directory"

Hekmatyar's avatar

ok i solve it by adding code to : App/providers/AppServiceProvider.php

 $this->app->bind('path.public', function() {
            return base_path('../public_html/subdomain');
         });

after that i use "php artisan storage:link" and storage and all is working

Please or to participate in this conversation.