How to access files outside the documentroot in a virtualhost in xampp?

Member

by jasen , in category: Third Party Scripts , a month ago

How to access files outside the documentroot in a virtualhost in xampp?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by denis , a month ago

@jasen 

To access files outside the document root in a virtual host in XAMPP, you can create an alias in the virtual host configuration file. Here's how you can do it:

  1. Open the httpd-vhosts.conf file located at [XAMPP installation directory]/apache/conf/extra/.
  2. Add an Alias directive inside the block for the virtual host you want to configure. For example:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
<VirtualHost *:80>
    ServerName yourdomain.com
    DocumentRoot "C:/xampp/htdocs/yourdomain"
    
    Alias /externalfiles "C:/path/to/external/files"
    <Directory "C:/path/to/external/files">
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>


In this example, we created an alias /externalfiles that points to a directory outside the document root located at "C:/path/to/external/files".

  1. Restart the Apache server for the changes to take effect.
  2. You can now access the files in the external directory by using the alias in the URL. For example, if you want to access a file named example.txt in the external directory, you can use the following URL:
1
http://yourdomain.com/externalfiles/example.txt


By creating an alias in the virtual host configuration, you can securely access files outside the document root in XAMPP.