Changing DocumentRoot for localhost only
-
I want to change the DocumentRoot only for "localhost".
Backstory: In LAN domain it.example.com pointing to my PC. I want to share under that domain one of my project from /laragon/www/ directory. By default under localhost Laragon shows /laragon/www content. How can i serve /laragon/www/example?
-
@michalp : You can change the setting in Menu > Laragon > Preferences
-
I know, but this way, all my new projects will be created inside that directory. I have many projects and want to share in LAN only one of them. Ngrok is not an option becouse of bad performance. I thought that easiest way to share my local application in LAN is to point domain to my ip and set DocumentRoot to directory that I want to share. Also it would be nice to have an option to change it easily.
-
@michalp : Ah, I see. There is also a topic like yours:
https://forum.laragon.org/topic/1127/how-to-use-proper-dir-and-virtual-hosts/9Let me check and get back to you soon.
-
I tried something like this (00-default.conf file):
AFTER:
define ROOT "C:/laragon/www/example/public/" define SITE "it.example.pl" <VirtualHost _default_:80> DocumentRoot "${ROOT}" ServerName ${SITE} ServerAlias *.${SITE} <Directory "${ROOT}"> AllowOverride All Require all granted </Directory> </VirtualHost>
BEFORE:
<VirtualHost _default_:80> <Directory "C:/laragon/www/"> AllowOverride All Require all granted </Directory> </VirtualHost>
Looks like it works, but let me know if this is not a proper way to do this.
-
@michalp : I'm glad to see you could make it. However, the 00-default.conf file may be re-generate. You should copy the content to a different file such as
example.conf
.