6

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:\laragon\etc\apache2\sites-enabled?

Nadiya
  • 382
  • 1
  • 7
  • 18

3 Answers3

15

The simple solution is to trick! Create another folder with the name project next to the my-new-project folder. Then go to C:\laragon\etc\apache2\sites-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:\laragon\etc\apache2\sites-enabled?

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

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

Guy Louzon
  • 1,175
  • 9
  • 19
  • it's not about to change the later part. ichanging.app to .local or any other keywords. Its about using different name which is different from the project direcory name – Nadiya Aug 11 '20 at 06:32
  • a naive question, why do you need this ? I mean, do you want the alias so that you can switch between folder easily ? – Guy Louzon Aug 11 '20 at 13:12
  • yes right. Firstly, i didn't know that i can change git tracked folder names. That's why i asked the question,. But still would like to know if this is possible to use a different name. – Nadiya Aug 12 '20 at 09:45
1

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:\laragon\etc\apache2\sites-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.
Tushar Saha
  • 647
  • 6
  • 13