Access a project with multiple URLs?


  • | 591 points

    I want to access a project on multiple URLs. As it possible to access one project with more the one URLs?
    I had tried to create second URL for a project by creating auto.project.test.conf but it is redirecting me to localhost.


  • | 6369 points

    🙏

    The objective can be attained in two steps:

    1. If you are using SSL, your auto.project.test.conf file might look like:
    define ROOT "F:/your/project/root"
    define SITE "project.test"
    
    <VirtualHost *:80>
        DocumentRoot "${ROOT}"
        ServerName ${SITE}
        ServerAlias *.${SITE}
        <Directory "${ROOT}">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    
    <VirtualHost *:443>
        DocumentRoot "${ROOT}"
        ServerName ${SITE}
        ServerAlias *.${SITE}
        <Directory "${ROOT}">
            AllowOverride All
            Require all granted
        </Directory>
    
        SSLEngine on
        SSLCertificateFile      F:/your/project/root/project.test.crt
        SSLCertificateKeyFile   F:/your/project/root/project.test.key
    
    </VirtualHost>
    

    Now, just change the URL part of define SITE with anything you want. Say, define SITE "another-project.test".

    If you are NOT using SSL, you will need to change the fields after ServerName and ServerAlias.

    1. Next, add a new entry to your host file for the new URL:
    ...
    ...
    ...
    
    127.0.0.1      project.test
    127.0.0.1      another-project.test
    

    Restart the server and you are done.

    NOTE: If you are using nginx, I dont know about the nginx, but following the first part you will be able to figure out what to change and where in the nginx configuration and second part is the same!

    😊


Log in to reply
 

Looks like your connection to Laragon was lost, please wait while we try to reconnect.