Page 1 of 1

Access XAMPP from External Hard Disk

PostPosted: 11. December 2020 01:07
by belajarxampp
Dear Expert,

I need your help since I have:

- XAMPP installed in C drive and
- XAMPP installed in D drive which is all of my htdocs files in D drive.

Problems:

- I opened XAMPP from C drive, then
- I type localhost/filename which is files located in D drive, and the result is nothing.

My question is:

1. How to access my all files in D drive when I type localhost/filename then it will show up?
2. Should I open XAMPP from C drive to get access all files in D drive with some edit on XAMPP? if yes, can you help me the step by step about how to.
3. OR should I open XAMPP from D drive in order to open htdocs files in D drive?

Highly appreciate if you can help me to solve this issue. Sorry, I am a newbie for this.

Thank you,

Alex

Re: Access XAMPP from External Hard Disk

PostPosted: 11. December 2020 12:26
by Nobbie
Do NOT install Xampp twice. Its sufficient to install Xampp to C:/xampp

If you need to access files from other folders or drives than c:/xampp/htdocs, use the ALIAS configuration option, see https://httpd.apache.org/docs/2.4/mod/mod_alias.html

For example, in your case:

Code: Select all
Alias /foldername d:/myfiles

With that configuration enter http://localhost/foldername/filename.html into browser to request d:/myfiles/filename.html

WARNING: External drive letters like d: are valid only for the logged in Windows User. If you are running Apache as a service (there is an option in Xampp Dialog), Apache is started from User "SYSTEM", which does NOT know d: drive. Therefore you MUST NOT start Apache as service, simply start it manually in the Xampp Dialog (not automatically) via clicking on Apache and MySQL start option. Otherwise you will get Error 403 or Error 404 when requesting http://localhost/foldername/filename.html

You also have to grant certain rights to Apache to access files on D: drive, at least add this configuration to your httpd.conf:

Code: Select all
<Directory "D:/myfiles" >
Require all granted
</Directory>