<p>Is it possible to configure <a href="http://www.apachefriends.org/en/xampp.html" rel="noreferrer">xampp</a> to serve up a file outside of the <code>htdocs</code> directory?</p>

<p>For instance, say I have a file located as follows:</p>

<p><code>C:\projects\transitCalculator\trunk\TransitCalculator.php</code></p>

<p>and my <a href="http://www.apachefriends.org/en/xampp.html" rel="noreferrer">xampp</a> files are normally served out from:</p>

<p><code>C:\xampp\htdocs\</code></p>

<p>(because that's the default configuration) Is there some way to make Apache recognize and serve up my <code>TransitCalculator.php</code> file without moving it under <code>htdocs</code>? Preferably I'd like Apache to serve up/have access to the entire contents of the projects directory, and I don't want to move the projects directory under <code>htdocs</code>.</p>

<p>edit: edited to add Apache to the question title to make Q/A more "searchable"</p>

[{'answer_id': 1413, 'author': 'sparkes', 'author_id': 269, 'author_profile': 'https://Stackoverflow.com/users/269', 'pm_score': 4, 'selected': False, 'text': "<p>You can set Apache to serve pages from anywhere with any restrictions but it's normally distributed in a more secure form.</p>\n\n<p>Editing your apache files (http.conf is one of the more common names) will allow you to set any folder so it appears in your webroot.</p>\n\n<p>EDIT:</p>\n\n<p>alias myapp c:\\myapp\\</p>\n\n<p>I've edited my answer to include the format for creating an alias in the http.conf file which is sort of like a shortcut in windows or a symlink under un*x where Apache 'pretends' a folder is in the webroot.  This is probably going to be more useful to you in the long term.</p>\n"}, {'answer_id': 1414, 'author': 'Dave Ward', 'author_id': 60, 'author_profile': 'https://Stackoverflow.com/users/60', 'pm_score': 7, 'selected': False, 'text': '<p>You can relocate it by editing the <strong>DocumentRoot</strong> setting in XAMPP\\apache\\conf\\httpd.conf.</p>\n\n<p>It should currently be:</p>\n\n<blockquote>\n  <p>C:/xampp/htdocs</p>\n</blockquote>\n\n<p>Change it to:</p>\n\n<blockquote>\n  <p>C:/projects/transitCalculator/trunk</p>\n</blockquote>\n'}, {'answer_id': 1421, 'author': 'cmcculloh', 'author_id': 58, 'author_profile': 'https://Stackoverflow.com/users/58', 'pm_score': 10, 'selected': True, 'text': '<p>Ok, per <a href="https://stackoverflow.com/questions/1408/#2471">pix0r</a>\'s, <a href="https://stackoverflow.com/questions/1408/#1413">Sparks</a>\' and <a href="https://stackoverflow.com/questions/1408/#1414">Dave</a>\'s answers it looks like there are three ways to do this:</p>\n\n<hr>\n\n<h2><a href="https://stackoverflow.com/questions/1408/#2471">Virtual Hosts</a></h2>\n\n<ol>\n<li>Open C:\\xampp\\apache\\conf\\extra\\httpd-vhosts.conf.</li>\n<li>Un-comment ~line 19 (<code>NameVirtualHost *:80</code>).</li>\n<li><p>Add your virtual host (~line 36):</p>\n\n<pre><code>&lt;VirtualHost *:80&gt;\n    DocumentRoot C:\\Projects\\transitCalculator\\trunk\n    ServerName transitcalculator.localhost\n    &lt;Directory C:\\Projects\\transitCalculator\\trunk&gt;\n        Order allow,deny\n        Allow from all\n    &lt;/Directory&gt;\n&lt;/VirtualHost&gt;\n</code></pre></li>\n<li><p>Open your hosts file (C:\\Windows\\System32\\drivers\\etc\\hosts).</p></li>\n<li><p>Add</p>\n\n<pre><code>127.0.0.1 transitcalculator.localhost #transitCalculator\n</code></pre>\n\n<p>to the end of the file (before the Spybot - Search &amp; Destroy stuff if you have that installed).</p></li>\n<li>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).</li>\n<li>Restart Apache.</li>\n</ol>\n\n<p>Now you can access that directory by browsing to <a href="http://transitcalculator.localhost/" rel="noreferrer">http://transitcalculator.localhost/</a>.</p>\n\n<hr>\n\n<h2><a href="https://stackoverflow.com/questions/1408/#1413">Make an Alias</a></h2>\n\n<ol>\n<li><p>Starting ~line 200 of your <code>http.conf</code> file, copy everything between <code>&lt;Directory "C:/xampp/htdocs"&gt;</code> and <code>&lt;/Directory&gt;</code> (~line 232) and paste it immediately below with <code>C:/xampp/htdocs</code> replaced with your desired directory (in this case <code>C:/Projects</code>) to give your server the correct permissions for the new directory.</p></li>\n<li><p>Find the <code>&lt;IfModule alias_module&gt;&lt;/IfModule&gt;</code> section (~line 300) and add</p>\n\n<pre><code>Alias /transitCalculator "C:/Projects/transitCalculator/trunk"\n</code></pre>\n\n<p>(or whatever is relevant to your desires) below the <code>Alias</code> comment block, inside the module tags.</p></li>\n</ol>\n\n<hr>\n\n<h2><a href="https://stackoverflow.com/questions/1408/#1414">Change your document root</a></h2>\n\n<ol>\n<li><p>Edit ~line 176 in C:\\xampp\\apache\\conf\\httpd.conf; change <code>DocumentRoot "C:/xampp/htdocs"</code> to <code>#DocumentRoot "C:/Projects"</code> (or whatever you want).</p></li>\n<li><p>Edit ~line 203 to match your new location (in this case <code>C:/Projects</code>).</p></li>\n</ol>\n\n<hr>\n\n<p><strong>Notes:</strong> </p>\n\n<ul>\n<li>You have to use forward slashes "/" instead of back slashes "\\".</li>\n<li>Don\'t include the trailing "/" at the end.</li>\n<li><em>restart your server</em>.</li>\n</ul>\n'}, {'answer_id': 2471, 'author': 'pix0r', 'author_id': 72, 'author_profile': 'https://Stackoverflow.com/users/72', 'pm_score': 6, 'selected': False, 'text': '<p>A VirtualHost would also work for this and may work better for you as you can host several projects without the need for subdirectories.  Here\'s how you do it:</p>\n\n<p>httpd.conf (or extra\\httpd-vhosts.conf relative to httpd.conf. Trailing slashes "\\" might cause it not to work):</p>\n\n<pre><code>NameVirtualHost *:80\n# ...\n&lt;VirtualHost *:80&gt;  \n    DocumentRoot C:\\projects\\transitCalculator\\trunk\\\n    ServerName transitcalculator.localhost\n    &lt;Directory C:\\projects\\transitCalculator\\trunk\\&gt;  \n        Order allow,deny  \n        Allow from all  \n    &lt;/Directory&gt;\n&lt;/VirtualHost&gt; \n</code></pre>\n\n<p>HOSTS file (c:\\windows\\system32\\drivers\\etc\\hosts usually):</p>\n\n<pre><code># localhost entries\n127.0.0.1 localhost transitcalculator.localhost\n</code></pre>\n\n<p>Now restart XAMPP and you should be able to access <a href="http://transitcalculator.localhost/" rel="noreferrer">http://transitcalculator.localhost/</a> and it will map straight to that directory.</p>\n\n<p>This can be helpful if you\'re trying to replicate a production environment where you\'re developing a site that will sit on the root of a domain name.  You can, for example, point to files with absolute paths that will carry over to the server:</p>\n\n<pre><code>&lt;img src="/images/logo.png" alt="My Logo" /&gt;\n</code></pre>\n\n<p>whereas in an environment using aliases or subdirectories, you\'d need keep track of exactly where the "images" directory was relative to the current file.</p>\n'}, {'answer_id': 480089, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>Solution to allow Apache 2 to host websites outside of htdocs:</p>\n\n<p>Underneath the "DocumentRoot" directive in httpd.conf, you should see a directory block. Replace this directory block with:</p>\n\n<pre><code>&lt;Directory /&gt;\n    Options FollowSymLinks\n    AllowOverride All\n    Allow from all\n&lt;/Directory&gt; \n</code></pre>\n\n<p><strong><em>REMEMBER NOT TO USE THIS CONFIGURATION IN A REAL ENVIRONMENT</em></strong></p>\n'}, {'answer_id': 4824442, 'author': 'Jason', 'author_id': 593201, 'author_profile': 'https://Stackoverflow.com/users/593201', 'pm_score': 4, 'selected': False, 'text': '<p>If you\'re trying to get XAMPP to use a network drive as your document root you have to use UNC paths in httpd.conf. XAMPP will not recognize your mapped network drives.</p>\n\n<p>For example the following won\'t work,\nDocumentRoot "X:/webroot"</p>\n\n<p>But this will,\nDocumentRoot "//192.168.10.100/webroot" (note the forward slashes, not back slashes)</p>\n'}]
['https://Stackoverflow.com/questions/1408', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/58/']