Run my php files from outside htdocs
Asked Answered
S

2

7

I have my xampp installed and running sites from the htdocs folder. I want to create a website directory in a different location and run the files online from there.

I know I can do this somehow using both Virtual Host settings and changing my hosts file in System32.

I want to change my URL from localhost/websites/mysite/ to just mysite/

Can anyone offer assistance, thank you

Shinn answered 6/9, 2013 at 22:35 Comment(1)
just put you folder mysite inside htdocs instead of websites folder. Check also this link https://mcmap.net/q/1039083/-xampp-change-document-rootMatthew
S
11

Locate httpd.conf file on your local XAMPP install: C:\xampp\xampp\apache\conf\httpd.conf

Edit the “DocumentRoot” line to the location of the remote \htdocs folder.

Example: “C:/xampp/xampp/htdocs” to “C:/Users/Ann/Documents/My Dropbox/Dev/Xampp/xampp/htdocs”

Edit the “Directory” tag to the same remote location you set for DocumentRoot.

“C:/Users/Ann/Documents/My Dropbox/Dev/Xampp/xampp/htdocs”

Save the file and restart your local Apache server.

Navigate to your "localhost” in your browser and you should see the remote web site files.

Skyla answered 6/9, 2013 at 22:44 Comment(0)
I
4

You don't have to configure anything and then reconfigure ...

What I do is the following: I have a simple PHP file in htdocs folder, named 'PHPexec.php', which accepts files from anywhere and it runs them as 'include' files. Example: Suppose you want to run "D:\PHPs\xxx.php'. You run http://localhost/PHPexec.php?f=D:\PHPs\xxx.php. PHPexec.php will receive the pathfile as a $_GET variable and run it as an 'include' file:

$file = $_GET['f'];  // After checking if it is set etc.
include $file;

Simple as that. From the moment you create your 'PHPexec.php', you have just to run http://localhost/PHPexec.php?f={PHP_file}. Your PHP file will be run as if it were stored in localhost! No configurations and re-configurations ...

(You can configure your 'PHPexec.php' to also accept variables to pass to the PHP file, etc.)

Iives answered 2/8, 2017 at 7:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.