Can you explain what directories your sub domains are pointing to?
They should all be pointing to the same Document Root as your primary domain, and its /public folder.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello! I have a laravel site and I want it to work with subdomains to like this:
domain.com -> Route principal subdomain1.domain.com -> agency1 subdomain2.domain.com -> agency2
all the subdomain are static and no dynamic.
I'm trying to use Route::domain like this
Route::domain('domain.com')->group(function () {
Route::get('/', function () {
return view('welcome');
});
Route::get('/testing', function() {
return view('home');
});
});
and
Route::domain('agency.domain.com')->group(function () {
Route::get('/', function () {
return view('home');
});
});
On local works perfectly but when I try this on my shared hosting this does not work I add the subdomain in the Subdomain section of cPanel but I get a 403 error.
Does anyone have try to do this on a shared hosting?
@ind1201259h8 on your interface in cPanel where you have your subdomains listed you should have a table grid
with the following headings:
Subdomains Document Root ▾ Redirection Actions
if you look down the Document Root Column you should have a little icon that looks like a house at the start and a pencil at the end. Click on the pencil and it will let you change the document root.
You need to change the document root of your 2 subdomains to point to the same folder as your primary domain
eg
/home/user/public_html/public
you want to checkout your whole project to /home/user/public_html/
you will also need to ask your ISP to change your primary domain webroot to /home/user/public_html/public too
Please or to participate in this conversation.