Make XAMPP / Apache serve file outside of htdocs folder
Ok, per pix0r's, Sparks' and Dave's answers it looks like there are three ways to do this:
Virtual Hosts
- Open C:\xampp\apache\conf\extra\httpd-vhosts.conf.
- Un-comment ~line 19 (
NameVirtualHost *:80
). Add your virtual host (~line 36):
<VirtualHost *:80>
DocumentRoot C:\Projects\transitCalculator\trunk
ServerName transitcalculator.localhost
<Directory C:\Projects\transitCalculator\trunk>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>Open your hosts file (C:\Windows\System32\drivers\etc\hosts).
Add
127.0.0.1 transitcalculator.localhost #transitCalculator
to the end of the file (before the Spybot - Search & Destroy stuff if you have that installed).
- Save (You might have to save it to the desktop, change the permissions on the old hosts file (right click > properties), and copy the new one into the directory over the old one (or rename the old one) if you are using Vista and have trouble).
- Restart Apache.
Now you can access that directory by browsing to http://transitcalculator.localhost/.
Make an Alias
Starting ~line 200 of your
http.conf
file, copy everything between<Directory "C:/xampp/htdocs">
and</Directory>
(~line 232) and paste it immediately below withC:/xampp/htdocs
replaced with your desired directory (in this caseC:/Projects
) to give your server the correct permissions for the new directory.Find the
<IfModule alias_module></IfModule>
section (~line 300) and addAlias /transitCalculator "C:/Projects/transitCalculator/trunk"
(or whatever is relevant to your desires) below the
Alias
comment block, inside the module tags.
Change your document root
Edit ~line 176 in C:\xampp\apache\conf\httpd.conf; change
DocumentRoot "C:/xampp/htdocs"
to#DocumentRoot "C:/Projects"
(or whatever you want).Edit ~line 203 to match your new location (in this case
C:/Projects
).
Notes:
- You have to use forward slashes "/" instead of back slashes "\".
- Don't include the trailing "/" at the end.
- restart your server.
how to configuring a xampp web server for different root directory
You can change Apaches httpd.conf by clicking (in xampp control panel) apache/conf/httpd.conf
and adjust the entries for DocumentRoot
and the corresponding Directory
entry.
Just Ctrl+F for "htdocs" and change the entries to your new path.
See screenshot:
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
How to browse to website outside of htdocs from remote computer
Solution by OP.
To accomplish my goal of accessing the pages from a remote computer I had to use the command mklink /J
. The example below created a directory named 'my' in my 'htdocs' linking to everything on my 'E:' drive.
mklink /J C:\xampp\htdocs\my E:
The only thing I don't like about it is that in order to view the webpage in E:/me, I have to type the URL example.com/my/me
instead of example.com/me
. I know it's not a big deal having to type the extra directory 'my' in the URL, but I just don't like the look of it. Also this negates the need to add 'VirtualHosts' and 'mapping'; although, I may have to do that anyway with '.htaccess' to keep users from accessing directories other than theirs.
XAMPP pointing a file outside root folder
It was chmod problem. I tried giving chmod -r 777 to Development folder, backbone folder and Backboneboilerplate.. It worked.
access xampp/htdocs from outside
You need a virtual host in Apache, that listens to at least the given IP (192.168.1.210:80
) or to any IP (*:80
):
<VirtualHost *:80>
ServerName localhost
DocumentRoot /var/www/some_app
</VirtualHost>
See: http://httpd.apache.org/docs/2.2/vhosts/examples.html
Please don't edit the httpd.conf
, as the changes might get lost on the next software update. You need to create a vHost inside the site-available
in den XAMPP/Apache folder.
XAMPP - PHP Going Outside Main Site Folder
Ok. I propose you a solution. Create a VirtualHost in your xampp, and this will probably fix your problem.
In you xampp\apache\conf\extra\httpd-vhosts.conf
, add this :
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/Testing
ServerName www.testing.com
</VirtualHost>
Now, in your C:\WINDOWS\system32\drivers\etc\
Open the "hosts" file :
127.0.0.1 www.testing.com
Finally, in your C:\xampp\apache\conf\httpd.conf
, scroll to the line VirtualHost and it should look like this :
#Virtual hosts
Include conf/extra/httpd-vhosts.conf
Change your css for this :
<link rel="stylesheet" href="/css/styles.css">
Restart your xampp server, and go to www.testing.com
in your browser.
Enjoy it !
Related Topics
How to Remove All Non Printable Characters in a String
Get Specific Columns Using "With()" Function in Laravel Eloquent
What's the Difference Between Isset() and Array_Key_Exists()
Replacing Accented Characters PHP
"Connect Failed: Access Denied For User 'Root'@'Localhost' (Using Password: Yes)" from PHP Function
Send File Attachment from Form Using PHPmailer and PHP
Is Closing the MySQL Connection Important
How to Set Order by Params Using Prepared Pdo Statement
Pdo Valid Characters For Placeholders
Get Table Column Names in MySQL
How to Extend a Class Using More Than 1 Class in PHP
How to Catch Curl Errors in PHP
Preserve Line Breaks from Textarea
Special Characters in Property Name of Object