Why is your DocumentRoot /var/www/mydomain.com? That should point to your public directory.
How to include subfolder in all requests?
Hello,
So far, my Laravel apps have been developed on localhost (Mamp/Herd) and have been hosted on separate subdomains, for example app1.mydomain.com. I am switching to self-hosting without subdomains, so this needs to become mydomain.com/app1, mydomain.com/app2 and so on.
The problem: on my webserver, only /app1/public/index.php loads, but all other content, such as images or the targets of internal links are not found (404). When inspecting a link for example, I see that its target is mydomain.com/dashboard, instead of mydomain.com/app1/dashboard.
I have tried the following:
- In .env:
APP_URL=https:// mydomain.com/app1 - In config/app.php:
'url' => env('APP_URL', 'https:// mydomain.com/app1'),
(Without the spaces after https://. I'm not allowed to post links here on my first day.)
Apparently, this does not suffice. And so I am trying to find an efficient way to include a subdirectory (the missing "/app1") in all requests my Laravel apps make to my webserver. This goes for routes, images and all other content.
I use React components instead of Blade. In these components, I also reference for example /images/x.jpg. (Images being a subfolder of /public.)
Thank you!
Off-topic - background info on my Apache2 webserver on Ubuntu. Should anyone know a better way, I'm all ears!
I have set up a virtual host for mydomain.com, and in its configuration file, have set the following:
ServerName mydomain.com
DocumentRoot /var/www/mydomain.com
Alias /app1 /websites/app1/public
<Directory /websites/app1/public>
AllowOverride All
Require all granted
</Directory>
I have used an alias because it is the only way I was able to make mydomain.com/app1 load /websites/app1/public.
Please or to participate in this conversation.