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

fardeen7337's avatar

Wildcard subdomain laravel

Hello, I have a project where everything is working fine. The admin is currently logging in using the auth package, and they can see all the data of companies. Each company has its own email/username and password.

Now, there's a new requirement: companies should be able to log in using the same browser if the admin is already logged in, or if another company is already logged in. Companies should access their login page using their subdomain, such as company1.test.com, company2.test.com, and so on.

I want the same functionality with subdomains for company login in the Laravel project. When a company logs in, they should only see their own data and be able to manage their own company.

Could you please guide me on how to achieve this both on localhost using XAMPP and on a live server using shared hosting?

Thank you.

0 likes
2 replies
rianmca's avatar

Even not use subdomain. The company can only see their data. What ur logic? If u want multiple domain you can set logic in your login page based ur company/domain. Then if u try in local using multiple domain if windows just use laragon. U using 2010 tech if u still using xampp. Using laragon for better host. Then u can point ur subdomain to main domain who have same view but different logic in frontend and backend.

Like this

// C:\Windows\System32\drivers\etc\hosts
127.0.0.1 trying.test
trying.test company1.trying.test

Dont forget to set trying.test automaticly on laragon

1 like
fardeen7337's avatar

but what about laravel auth package when you try login by using admin url (domain) it logins and when we try to login at a same time with subdomain so the login page opens but when you submit the login it's not login

same auth use for multiple subdomains and domains what about this?

Please or to participate in this conversation.