How to Redirect a Subdomain to a Page Path in Laravel

If you want a subdomain point to a route on a Laravel app that is hosted on a say AWS VM with a static IP:

For example:

test.example.com -> 1.2.3.4

or

test.example.com/someform -> 1.2.3.4/someform

Create an A record (on the domain registrar)

point subdomain to the base IP of the VM where the Laravel app is listening

Do the following entry in VirtualHost config

<VirtualHost 127.0.0.1:80>
    ServerName test.example.com
    
    ProxyPass /test !

    Alias /test "/opt/bitnami/projects/appname/public/someform"
     <Directory "/opt/bitnami/projects/appname/public/someform">
        Options -Indexes +FollowSymLinks -MultiViews
        AllowOverride All
        Require all granted
     </Directory>
</VirtualHost>
comments powered by Disqus