Relocate DocumentRoot of a Virtual Host to a different drive

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Relocate DocumentRoot of a Virtual Host to a different drive

Postby John Eng » 17. January 2021 21:28

Hi

I have created a virtual host named test.local which works (who knew!)
<VirtualHost 127.0.0.1>
DocumentRoot "C:/xampp/htdocs/Web Site 1"
ServerName test.local
</VirtualHost>

However, I would like to relocate Web Site 1 from drive C to a new folder on drive E.
I tried DocumentRoot Alias "C:/xampp/htdocs/Web Site 1" "E:/Docs Web Dev/Web Sites/Web Site 1" but Apache would not start.

How do I do this? Your help would be most appreciated!

Thank you.
John Eng
 
Posts: 2
Joined: 17. January 2021 20:12
XAMPP version: 8.00
Operating System: Windoes 7

Re: Relocate DocumentRoot of a Virtual Host to a different d

Postby Altrea » 18. January 2021 01:05

Hi,

Why using Alias? Alias is the right choice if you want to point a part of the url to a different physical place like grabbing all file requests from http://localhost/images from a place where all of your website images are saved. It is not the right choice to relocate an entire DocumentRoot and it cannot change one physical path to another, only part of URLs to paths.

You only need to change the DocumentRoot line and write a new access rule for the new folder.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11948
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: Relocate DocumentRoot of a Virtual Host to a different d

Postby Nobbie » 18. January 2021 11:16

What is drive E:? As Altrea already said, you have to change DocumentRoot to E:/Docs.... but drive letters from network drives (for example) are only known to the logged in Windows User. If you are running Apache as a service, it runs with SYSTEM User instead and wont know E:. Same for USB Sticks etc., only drive letters from builtin harddrives are known to all users.
Nobbie
 
Posts: 13208
Joined: 09. March 2008 13:04

Re: Relocate DocumentRoot of a Virtual Host to a different d

Postby John Eng » 18. January 2021 22:21

Thanks Altrea and Nobbie,

As per Altrea's instructions I added,

284 ServerName test.local:80

286 <Directory "E:/Docs Web Dev/Web Sites/Web Site 1">
287 AllowOverride All
288 Options None
289 Require local
290 </Directory>

and corrected,

583 <VirtualHost 127.0.0.1>
584 DocumentRoot "E:/Docs Web Dev/Web Sites/Web Site 1"
586 ServerName test.local
587 </VirtualHost>

and it worked!!!!!!!!!!!!! Wow!!!!

This is all new to me as you can tell.

Thanks again. Much appreciated.
John Eng
 
Posts: 2
Joined: 17. January 2021 20:12
XAMPP version: 8.00
Operating System: Windoes 7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests