Reputation: 53
I created an subdomain for my Laravel application and deployed it on it. (Example: sub.domain.com)
When I try to access sub.domain.com
I get A 403 Error
because the index.php was not found and is located in the public/ folder of my project. I know that i can move all of the files from the public folder and put them in the root of the project, but is this the only way to accomplish this? I also tried to create a symlink, but that won't work for me either.
Is there a "Laravel solution" for this problem? (I am using Laravel Framework 7.12.0
)
Upvotes: 0
Views: 2805
Reputation: 1822
You should point your subdomain to specific folder. If you are using shared hosting check your cPanel where subdomain is pointing. There should be Root directory for that subdomain and it should point to your public folder. Then with Laravel you can do your logic.
Another way is with htaccess
RewriteEngine on
RewriteBase /
# Rewrites all URLS [Replace "example" with the actual domain, without the TLD (.com, .net, .biz, etc)]
RewriteCond %{HTTP_HOST} ^(sub\.)?example\.
# Rewrite all those to insert /folder
RewriteRule ^(.*)$ /public/$1 [L]
It depends where your subdomain is pointing at first. If it is outside your main domain you can't redirect it htaccess
Upvotes: 2