How To Serve Your PHP Files Outside Of htdocs

Ten simple steps to change the hosting PHP folder

leanscript
3 min readSep 30, 2020

Serving your PHP files outside of the default htdocs folder can be useful for many reasons. The reason I did it was that I have no more room in my main C: drive left, but I have an abundant amount of open space left of my D: drive. The tutorials found on the internet are very confusing and unnecessarily long. Here is an easy way to accomplish this task.

  1. Open your Xampp Control Panel and under Apache, click the config button to be able to select the Apache (httpd.conf) option.

2. Notepad will open the file and you will need to find the highlighted section below.

3. Go ahead and copy and paste the highlighted section directly below.

4. You should now have two identical <Directory> blocks.

5. Now change the highlighted section to the destination you would like your PHP files to be served in. I have changed my destination to my D: drive D:/phpdocs

6. You will need to scroll down just a little bit until you find this section.

7. Copy Alias /webpath /full/filesystem/path and paste it right below ScriptAlias /cgi-bin/ “C:/xampp/cgi-bin/”. Modify the alias to reflect the new destination like so.

8. Save the file and close notepad.

9. Open your Xampp Control Panel back up again and and stop your Apache server.

10. Once the server stops. Go ahead and start it back up again.

Great, that is all there is to change the destination. Now you can go to the new destination in your browser. Mine is localhost/phpdocs

--

--