Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate an Alias Directory inside a Virtual Host
    text
    copied!<p><em>I checked <a href="https://stackoverflow.com/questions/5552081/using-a-directory-in-virtualhost-servername">here</a>, <a href="http://www.rafael-chacon.com/post/9903470026/rails-wordpress-apache-integration" rel="nofollow noreferrer">here</a>, <a href="http://www.nodans.com/index.cfm/2006/10/10/Apache-Directory-Aliases-and-Virtual-Directories" rel="nofollow noreferrer">here</a>, <a href="http://httpd.apache.org/docs/current/mod/core.html" rel="nofollow noreferrer">here</a>, and <a href="http://httpd.apache.org/docs/2.0/mod/mod_alias.html" rel="nofollow noreferrer">here</a> before asking this question. I guess my search skills are weak.</em></p> <p>I am using the <a href="http://www.wampserver.com/en/" rel="nofollow noreferrer">WampServer</a> version <code>2.2e</code>. I have a need like, I need a virtual path inside a virtual host. Let me say the two hosts that I have.</p> <h3>Primary Virtual Host (Localhost)</h3> <pre><code>NameVirtualHost *:80 &lt;VirtualHost *:80&gt; ServerName localhost DocumentRoot "C:/Wamp/www" &lt;/VirtualHost&gt; </code></pre> <h3>My Apps Virtual Hosts</h3> <pre><code>&lt;VirtualHost *:80&gt; ServerName apps.ptrl DocumentRoot "C:/Wamp/vhosts/ptrl/apps" ErrorLog "logs/apps-ptrl-error.log" CustomLog "logs/apps-ptrl-access.log" common &lt;Directory "C:/Wamp/vhosts/ptrl/apps"&gt; allow from all order allow,deny AllowOverride All &lt;/Directory&gt; DirectoryIndex index.html index.htm index.php &lt;/VirtualHost&gt; </code></pre> <h3>My Blog Virtual Host</h3> <pre><code>&lt;VirtualHost *:80&gt; ServerName blog.praveen-kumar.ptrl DocumentRoot "C:/Wamp/vhosts/ptrl/praveen-kumar/blog" ErrorLog "logs/praveen-kumar-ptrl-error.log" CustomLog "logs/praveen-kumar-ptrl-access.log" common &lt;Directory "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"&gt; allow from all order allow,deny AllowOverride All &lt;/Directory&gt; DirectoryIndex index.html index.htm index.php &lt;/VirtualHost&gt; </code></pre> <p>My requirement now is to have <code>http://apps.ptrl/blog/</code> and <code>http://blog.praveen-kumar.ptrl/</code> should be the same directory. One thing I thought of is, moving the <code>blog</code> folder inside the <code>apps</code> folder, but it is connected with <code>Git</code> and other stuffs are there, so it is not possible to move the folder.</p> <p>So, I thought of creating an <code>alias</code> to the <code>VirtualHost</code> in this way:</p> <pre><code>&lt;VirtualHost *:80&gt; ServerName apps.ptrl DocumentRoot "C:/Wamp/vhosts/ptrl/apps" ErrorLog "logs/apps-ptrl-error.log" CustomLog "logs/apps-ptrl-access.log" common &lt;Directory "C:/Wamp/vhosts/ptrl/apps"&gt; allow from all order allow,deny AllowOverride All &lt;/Directory&gt; DirectoryIndex index.html index.htm index.php # The alias to the blog! Alias /blog "C:/Wamp/vhosts/ptrl/praveen-kumar/blog" &lt;Directory "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"&gt; allow from all order allow,deny AllowOverride All &lt;/Directory&gt; &lt;/VirtualHost&gt; </code></pre> <p>But when I tried to access <code>http://apps.ptrl/blog</code>, I am getting an <code>Error 403 Forbidden</code> page.</p> <p><img src="https://i.stack.imgur.com/3MoWU.png" alt="Forbidden"></p> <p>Am I doing the right thing? If you need to look at the access log, and error log, they are here:</p> <pre><code># Access Log 127.0.0.1 - - [14/Oct/2012:09:53:11 +0530] "GET /blog HTTP/1.1" 403 206 127.0.0.1 - - [14/Oct/2012:09:53:11 +0530] "GET /favicon.ico HTTP/1.1" 404 209 127.0.0.1 - - [14/Oct/2012:09:53:53 +0530] "GET / HTTP/1.1" 200 6935 127.0.0.1 - - [14/Oct/2012:09:53:53 +0530] "GET /app/blog/thumb.png HTTP/1.1" 404 216 # Error Log [Sun Oct 14 09:53:11 2012] [error] [client 127.0.0.1] client denied by server configuration: C:/Wamp/vhosts/ptrl/praveen-kumar/blog [Sun Oct 14 09:53:11 2012] [error] [client 127.0.0.1] File does not exist: C:/Wamp/vhosts/ptrl/apps/favicon.ico [Sun Oct 14 09:53:53 2012] [error] [client 127.0.0.1] File does not exist: C:/Wamp/vhosts/ptrl/apps/app/blog, referer: http://apps.ptrl/ </code></pre> <p>Waiting eagerly for some help. I am ready to provide more info, if needed.</p> <hr> <h2>Update #1: Changed VirtualHosts declaration according to the instructions given by <a href="https://stackoverflow.com/users/1262820/felipsmartins">felipsmartins</a>:</h2> <pre><code>&lt;VirtualHost *:80&gt; ServerName apps.ptrl DocumentRoot "C:/Wamp/vhosts/ptrl/apps" ErrorLog "logs/apps-ptrl-error.log" CustomLog "logs/apps-ptrl-access.log" common # The alias to the blog! Alias /blog "C:/Wamp/vhosts/ptrl/praveen-kumar/blog" &lt;Directory "C:/Wamp/vhosts/ptrl/praveen-kumar/blog"&gt; allow from all order allow,deny AllowOverride All &lt;/Directory&gt; &lt;Directory "C:/Wamp/vhosts/ptrl/apps"&gt; allow from all order allow,deny AllowOverride All &lt;/Directory&gt; DirectoryIndex index.html index.htm index.php &lt;/VirtualHost&gt; </code></pre> <hr> <h2>Update #2: Another Issue:</h2> <p>I am able to access the site. The physical links are working now. i.e., I am able to open <code>http://apps.ptrl/blog/index.php</code> but not <code>http://apps.ptrl/blog/view-1.ptf</code>, which gets translated to <code>http://apps.ptrl/blog/index.php?page=view&amp;id=1</code>. Any solutions?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload