skip to Main Content

I’ve a project named ‘my-new-project’ (that’s just an example). With laragon auto virtual host name feature, i can browse this project via http://my-new-project.test/

Is it possible to browse this project with another name instead of this project name like… http://project.test/?

Also, what is ServerName and ServerAlias located in .conf file inside C:laragonetcapache2sites-enabled?

3

Answers


  1. I’ve found the instructions part that might be useful under a different search:
    enter link description here

    from which:

    …At this point, I’ve made a {name}.local, so let’s say, the URL in
    my wordpress directory is http://wordpress.local. You can either set
    something as you like, or, leave the default one. When launching Auto
    Virtual Hosts, press Yes to allow any permissions in Windows. These
    Auto Virtual Hosts automatically edit your hosts file. You no longer
    need to write the hosts file.

    enter image description here

    Login or Signup to reply.
  2. The simple solution is to trick!
    Create another folder with the name project next to the my-new-project folder.
    Then go to C:laragonetcapache2sites-enabled path and edit auto.project.test.conf.
    Edit these:

    <VirtualHost *:80> 
    DocumentRoot "C:/laragon/www/project"
    ServerName project.test
    ServerAlias *.project.test
    <Directory "C:/laragon/www/project">
        AllowOverride All
        Require all granted
    </Directory>
    

    to these:

    <VirtualHost *:80> 
    DocumentRoot "C:/laragon/www/my-new-project"
    ServerName project.test
    ServerAlias *.project.test
    <Directory "C:/laragon/www/my-new-project">
        AllowOverride All
        Require all granted
    </Directory>
    

    This is the simple way.

    and for this question:

    Also, what is ServerName and ServerAlias located in .conf file inside C:laragonetcapache2sites-enabled?

    go to this link:
    What is the difference between ServerName and ServerAlias in apache2 configuration?

    Login or Signup to reply.
  3. The auto create virtual host option create host for all folders those are present in root server directory. You can check or change your root server directory form preference (the gear icon).
    The domain name will be (your-folder-name).test

    These steps worked for me.

    1. Go to root server directory and create a folder for your project. (eg. my-project).
    2. Go to C:laragonetcapache2sites-enabled.
    3. Here you will find your project folder .conf file (ex. auto.my-project.test.conf). If you don’t find it restart your server.
    4. Edit the .conf file. You will find something like bellow
    <VirtualHost *:80> 
        DocumentRoot "F:/Programs/Php-Projects/my-project"
        ServerName my-project.test
        ServerAlias *.my-project.test
        <Directory "F:/Programs/Php-Projects/my-project">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    
    # If you want to use SSL, enable it by going to Menu > Apache > SSL > Enabled
    
    1. My project root is in F:/Programs/Php-Projects/ it can be set in Laragon preference. It can be set to be a directory other then "C".
    2. Now here one can change the project root and name of the host.
      • for directory change DocumentRoot and Directory
      • and for host change ServerName and ServerAlias
    • Note: Document root can be other then the actual directory. Sometime it is necessary to create folder in root just to create a virtual host. (Ex. my folder path is F:/Programs/Php-Projects/my-project and my project path is F:/Programs/Php-Projects/laravel/my-project and it works fine.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search