2

I'm using Laragon on Windows 10, and I want to create a subdomain for a new project, The current structure is:

https://management.test
https://management.test/includes
https://management.test/client

I want to access the client folder using this URL: https://client.management.test But I don't want to have https://includes.management.test

I want the configuration to be only on the client folder.

I've tried playing with the Apache sites-enabled file but didn't get the result, Can anyone share a working example with me or a simple solution to achieve this?

Thank you.

Tao
  • 39
  • 1
  • 5

1 Answers1

2

I just figured this out. This "manual" solution worked for me

  • I edited drivers\etc\hosts and added my subdomain like
127.0.0.1    sub.project.test
  • Enable mod_vhost_alias.so in laragon\bin\apache[version]\conf\httpd.conf

  • Create a new file like {laragon folder}\etc\apache2\sites-enabled\sub.project.test.conf"

  • Add the following code in the file you just created

define ROOT "C:/laragon/htdocs/project/sub/"
define SITE "sub.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      C:/laragon/etc/ssl/laragon.crt
    SSLCertificateKeyFile   C:/laragon/etc/ssl/laragon.key
 
</VirtualHost>

Replace ROOT to the path to the subdomain folder

  • Finally reload apache and visit the subdomain

References :