Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

msaad's avatar
Level 1

Laravel 8 Project Hosting 403 Error

Hello Friend, I want to ask about laravel project hosting.

I upload my laravel 8 projects on the server. When I visit my website it returns a 403 error and when trying to access another page of the website it returns a 404 error. I just change my .env file.

Plz, help me.

0 likes
27 replies
automica's avatar

have you cleared all the caches on your remote server after uploading the site?

php artisan optimize:clear

should empty all caches.

you should also ensure you have correct file permissions for folders and files.

Good practice is to set all your directories to 755 and all of your files to 644… SET file permissions using the following command:

sudo find /path/to/your/laravel-directory -type f -exec chmod 644 {} \;

SET directory permissions:

sudo find /path/to/your/laravel-directory -type d -exec chmod 755 {} \;

1 like
msaad's avatar
Level 1

I try this by artisan::call but it returns a 404 error. Yes, all directories set to 755 and all the files to 644.

ImeDa's avatar

Set debug=true in .env file and copy/paste the error code here.

msaad's avatar
Level 1

I set debug: true but it returns the same error of 403

Forbidden You don't have permission to access this resource.

Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.

ImeDa's avatar

Which hosting provider is it ? And how did you handle server setup staff ?

msaad's avatar
Level 1

I use go daddy hosting. My dad handle server setup staff. Tell me which requirement is required.

ImeDa's avatar

As I know, godaddy is shared hosting, so the setup could be different, are you pointing to correct document root directory ? it should be public folder.

ImeDa's avatar

If the document root is correct, then it has to be the problem with file permissions. If you are not aware how it works, just set 777 on your storage folder and see if it helps, but don't forget to revert it back (its a bad thing for security). You can copy storage folder into another folder and then change the permissions, then see if it works and remove the storage folder again, and rename the copied folder to its original name (storage).

If you are not aware how to change file permissions in godaddy admin panel, just google it.

Tell me if it helps, 403 could be caused by a lot of things and you have to try some things, before you figure it out.

ImeDa's avatar

Yeah, but you had to change document root in your apache configuration. It you have shared hosting, it has to be somewhere in the admin panel.

Quick check: Make an index.html or index.php file in your project and see if it changes something.

msaad's avatar
Level 1

@imeda Yeah I create an index.html file and it works fine. but when I try to access the page through routes it returns a 403 error. How can I solve this issue?

msaad's avatar
Level 1

@imeda apache

document root

/public_html/web/

or need to change.

I also want to ask that after deployment every folder and file remains the same as in localhost or need to change any file or folder location or name

ImeDa's avatar
ImeDa
Best Answer
Level 3

Change document root to /public_html/web/public if your project is web, if not, change it to /path/to/your/project/public

ImeDa's avatar

Look into storage/logs directory and check if there are any errors logged. Command example:

tail -300 storage/logs/laravel.log.      // Change laravel.log file name to latest file name by date

If there are no errors logged, then you have a permission problem and see @automica 's answer.

jlrdw's avatar

Are you pointing to public for document root?

neoish's avatar

It seems to me that Apache might not be configured properly. I don't think the request is getting to your Laravel application. Can you post your apache (and/or .htaccess) configuration

2 likes
msaad's avatar
Level 1

@neoighodaro I don't make any change in the .htaccess file. it is default from the laravel project

<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>

Rida Makhchan's avatar

Domain name don't achieve your Laravel project, May be issue is with vhost config. If you're using Apache (httpd) then I doubt you need to add <Directory> section to the <VirtualHost>:

<VirtualHost *:80>
...
<Directory "/url/to/your/public">
                AllowOverride All
                Order Allow,Deny
                Allow from all
</Directory>
...
</VirtualHost>

alidamar's avatar

hi guys, i have same error. i'm trying all way but it's not working what can i do ? thx.

alidamar's avatar

@msaad path is true,

server { server_name istocakasya.com www.istocakasya.com; root /var/www/istocakasya.com/public/;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.php;

charset utf-8;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }
error_log /var/log/nginx/error_log;
error_page 404 /index.php;

     location ~ .php$ {
    fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    include fastcgi_params;
}

location ~ /.(?!well-known).* {
    deny all;
}

listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/istocakasya.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/istocakasya.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

} server { if ($host = www.istocakasya.com) { return 301 https://$host$request_uri; } # managed by Certbot

if ($host = istocakasya.com) {
    return 301 https://$host$request_uri;
} # managed by Certbot


listen 80;
listen [::]:80;
server_name istocakasya.com www.istocakasya.com;
return 404; # managed by Certbot

}

msaad's avatar
Level 1

@alidamar My error is solved just by checking and updating my path to the public folder

My Updated path which works for me: public_html/theaconnection.com/public

alidamar's avatar

my thread. laracasts.com/discuss/channels/laravel/other-page-403-forbidden-error

Please or to participate in this conversation.