{"id":13316,"date":"2014-02-24T08:55:57","date_gmt":"2014-02-24T08:55:57","guid":{"rendered":"http:\/\/tom.ji42.com\/?p=13316"},"modified":"2014-02-24T08:55:57","modified_gmt":"2014-02-24T08:55:57","slug":"how-to-add-virtual-directory-alias-on-apache-xampp","status":"publish","type":"post","link":"https:\/\/tom.tomwork.net\/?p=13316","title":{"rendered":"How to Add Virtual Directory Alias on Apache Xampp"},"content":{"rendered":"<p>Do you want to create some\u00a0<code>alias<\/code>\u00a0or you can call it\u00a0<em>virtual directory<\/em>\u00a0on Apache Xampp? I\u2019m using Windows Xampp as an example here. If you\u2019re using Linux, you just need to adjust the path.<\/p>\n<h2>Why do you need an alias or virtual directory?<\/h2>\n<p>Supposed you have installed Xampp on some directories, like:<\/p>\n<pre><code>C:\\Program Files\\xampp\\<\/code><\/pre>\n<p>And the default document root would be in:<\/p>\n<pre><code>C:\\Program Files\\xampp\\htdocs<\/code><\/pre>\n<p><!--more-->But, my source code are all outside that\u00a0<code>htdocs<\/code>\u00a0directory, example:<\/p>\n<pre><code>D:\\sources<\/code><\/pre>\n<p>I know that the most easiest way is to copy and paste all of them into\u00a0<code>htdocs<\/code>\u00a0directory. But that\u2019s not what I want to be.<\/p>\n<p>So, I decided to add an\u00a0<code>alias<\/code>\u00a0or\u00a0<em>virtual directory<\/em>\u00a0in my Apache web server.<\/p>\n<h2>How do I do that?<\/h2>\n<ol>\n<li>Open the\u00a0<code><strong>httpd.conf<\/strong><\/code>\u00a0file, it\u2019s located in this directory:\n<pre><code>C:\\Program Files\\xampp\\apache\\conf<\/code><\/pre>\n<\/li>\n<li>Add these lines on the bottom of the\u00a0<code>httpd.conf<\/code>\u00a0file:\n<pre><code>Alias <strong>\/sources<\/strong> \"<strong>D:\/sources<\/strong>\"\r\n\r\n&lt;Directory \"<strong>D:\/sources<\/strong>\"&gt;\r\n\tOptions Indexes FollowSymLinks Includes ExecCGI\r\n\tAllowOverride All\r\n\tOrder allow,deny\r\n\tAllow from all\r\n&lt;\/Directory&gt;<\/code><\/pre>\n<p>Pay attention to the\u00a0<strong>bold<\/strong>\u00a0parts. In Windows, normally we\u2019re using\u00a0<strong>\u201cBackslash\u201d<\/strong>\u00a0or\u00a0<strong>\\<\/strong>, but here we\u00a0<span style=\"text-decoration: underline;\">must<\/span>\u00a0use\u00a0<strong>\u201cForward Slash\u201d<\/strong>\u00a0or\u00a0<strong>\/<\/strong><\/li>\n<li>Restart your Xampp<\/li>\n<li>Open your web browser and test it by go to\u00a0<code>http:\/\/localhost\/sources<\/code><\/li>\n<\/ol>\n<p>Hope it helps. If you found some error while doing it, just leave a comment here, maybe I can help you out.<\/p>\n<p><em><strong>\u2013 Updated: February 24, 2013 \u2013<\/strong><\/em><\/p>\n<p>If you\u2019re getting error 403 Forbidden like these:<\/p>\n<pre><code><strong>Access forbidden!<\/strong>\r\nYou don't have permission to access the requested directory. There is either no index document or the directory is read-protected.\r\nIf you think this is a server error, please contact the webmaster.\r\nError 403<\/code><\/pre>\n<p>Maybe you can add this line inside the\u00a0<code>&lt;Directory&gt;&lt;\/Directory&gt;<\/code>\u00a0block:<\/p>\n<pre><code>Require all granted<\/code><\/pre>\n<p>So, the final code will be like this:<\/p>\n<pre><code>Alias <strong>\/sources<\/strong> \"<strong>D:\/sources<\/strong>\"\r\n\r\n&lt;Directory \"<strong>D:\/sources<\/strong>\"&gt;\r\n\tOptions Indexes FollowSymLinks Includes ExecCGI\r\n\tAllowOverride All\r\n\tOrder allow,deny\r\n\tAllow from all\r\n\tRequire all granted\r\n&lt;\/Directory&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Do you want to create some\u00a0alias\u00a0or you can call it\u00a0virtual directory\u00a0on Apache Xampp? I\u2019m using Windows Xampp as an example here. If you\u2019re using Linux, you just need to adjust the path. Why do you need an alias or virtual directory? Supposed you have installed Xampp on some directories, like: C:\\Program Files\\xampp\\ And the default [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-13316","post","type-post","status-publish","format-standard","hentry","category-13"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6cOVM-3sM","_links":{"self":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/13316","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13316"}],"version-history":[{"count":1,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/13316\/revisions"}],"predecessor-version":[{"id":13317,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/13316\/revisions\/13317"}],"wp:attachment":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}