Working with wildcard subdomains


  • | 1660 points

    I am working on a website where I will use langage subdomains. Let's say my website domain in laragon is mysite.dev, I want to have any subdomains ending in the same directory as the root domain.

    Even though laragon virtualhost seems to do the wildcard thingy, I can't get any subdomain working unless i edit my hosts file like so :

    127.0.0.1       localhost
    127.0.0.1      mysite.dev        #laragon magic!   
    127.0.0.1      en.mysite.dev        #laragon magic!   
    

    With this very host file, mysite.dev and en.mysite.dev will work but not de.mysite.dev. And there is no way to do a wilcard thingy in the hosts file. Do you have any clues ?

    Here is my mysite.dev vhosts file :

    define ROOT "C:/laragon/www/mysite/public/"
    define SITE "mysite.dev"
    
    <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/mysite.dev.crt
        SSLCertificateKeyFile   C:/laragon/etc/ssl/mysite.dev.key
     
    </VirtualHost>

  • administrators
    | 66720 points

    @Lelectrolux :
    Windows hosts file does not support wildcard domain, but you can copy it manually easily. However, you should not include '#laragon magic!' for manual entries.
    Your hosts file should like this:

    127.0.0.1       localhost
    127.0.0.1      mysite.dev        #laragon magic!   
    127.0.0.1      en.mysite.dev       
    127.0.0.1      de.mysite.dev   
    

    If you have many other subdomains, consider using this free DNS server:
    http://mayakron.altervista.org/wikibase/show.php?id=AcrylicHome


Log in to reply
 

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