Can we somehow do this. I am showing the example but we can change the below code.
<Location />
DocumentRoot /var/www/html/app1/public
</Location>
<Location /app2>
DocumentRoot /var/www/html/app2/public
</Location>
CodePudding user response:
Not specific to laravel. If you want Apache to serve files for 2 different applicatication then set up virtual hosts in the Apache config files
# Ensure that Apache listens on ports
Listen 80
Listen 81
Listen 82
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
# Other directives here
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
# Other directives here
</VirtualHost>
<VirtualHost *:81>
DocumentRoot "/www/example3"
# Other directives here
</VirtualHost>
<VirtualHost *:82>
DocumentRoot "/www/example4"
# Other directives here
</VirtualHost>
CodePudding user response:
What i need ex: 192.168.1.23 will open app1 and 192.168.1.23/app2 will open app1
In this case you can use the Alias
directive, like so:
<VirtualHost *:80>
DocumentRoot /var/www/html/app1/public
Alias /app2 /var/www/html/app2/public
# add other directives here
</VirtualHost>
This will map the filesystem contents of /var/www/html/app2/public
to /app2
while the default Document Root (/
) will be /var/www/html/app1/public
.
I recommend you have a look at the documentation here, it gives a very good explanation for different solutions to your problem: https://httpd.apache.org/docs/2.4/urlmapping.html