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

Khin Zin Zin Thinn's avatar

403 Forbidden Access on SubDomain (cPanel & Litespeed Web Server).

I am now trying to deploy a Laravel project on a subdomain of shared hosting with cPanel (LItespeed Web Server).

  1. Created a subdomain (subdomain.example.com)
  2. Uploaded a Laravel project on it
  3. Can access the project via subdomain.example.com/public/index.php
  4. Can't access the project via subdomain.example.com (403 Forbidden)

I tried adding a .htaccess file at the root directory (of subdomain.example.com)

<IfModule>
Options +FollowSymLinks
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ public/index.php [L]
</IfModule>

Nothing changes after the update of .htaccess and it just keeps working the same.

(I would like to solve this with .htaccess only. SO, please help me with this, guys. Thanks)

0 likes
7 replies
momagdi's avatar

I normally would configure the subdomain directory in cPanel like follow:

/public_html/subdomain.example.com/public/

this way when you access subdomain.example.com it would work out of the box and you keep project structure, and no .htaccess configuration needed.

Khin Zin Zin Thinn's avatar

@momagdi Thanks for your reply. I already tried that. It doesn't work properly. If I go with this, I can't get access to subdomain.example.com/dashboard though other urls are working fine (also images from storage are returning 404 - I already run php artisan storage:link). I don't know why. That's why I included that I only want to go with .htaccess. Maybe it's also good if the cpanel solution works fine.

Khin Zin Zin Thinn's avatar

I tried to access the subdomain.example.com/dashboard but it automatically redirects to subdomain.example.com/public/dashboard and displays 404 error.

Snapey's avatar

@momagdi and what do you get at /public_html/subdomain.example.com/.env ??????

Khin Zin Zin Thinn's avatar

@Snapey btw, in my cPanel, subdomain directory is not under public_html. The directory is separately created under username 'subdomain.example.com'.

Khin Zin Zin Thinn's avatar

@Snapey

APP_NAME=Applica
APP_ENV=local
APP_KEY=base64:4qXUWGJoxaEOhIEOx6DrrM+4bSLkJAc80txrGAwcsW8=
APP_DEBUG=true
APP_URL=http://applica.test
momagdi's avatar

if you want to solve the application URL issue via .htaccess, add the following to your (laravel) root directory:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?subdomain.example.com$
RewriteCond %{REQUEST_URI} !^/public/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /public/
RewriteCond %{HTTP_HOST} ^(www.)?subdomain.example.com$
RewriteRule ^(/)?$ public/index.php [L]

this will set /public as the root directory for the application.

Please or to participate in this conversation.