Note that there are some explanatory texts on larger screens.

plurals
  1. PORoot requests resolving to wrong VirtualHost in Apache
    text
    copied!<p>I have two web sites running behind an Apache server.</p> <p>One of them serves requests to api.xyzzy.com</p> <p>The other serves any other traffic that comes in (dozens of domains, subdomains, etc) and is thus a catch-all wildcard.</p> <p>Using the config below, requests to deep links under <a href="http://api.xyzzy.com/" rel="nofollow">http://api.xyzzy.com/</a>... go to the correct virtual host (the first one), but top-level requests to <a href="http://api.xyzzy.com/" rel="nofollow">http://api.xyzzy.com/</a> load the second catch-all wildcard virtual host instead. </p> <p>What have I done wrong here?</p> <pre><code>LoadModule passenger_module /home/webby/.rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.18/ext/apache2/mod_passenger.so PassengerRoot /home/webby/.rvm/gems/ruby-1.9.3-p286/gems/passenger-3.0.18 PassengerRuby /home/webby/.rvm/wrappers/ruby-1.9.3-p286/ruby NameVirtualHost *:80 &lt;VirtualHost *:80&gt; ServerName api.xyzzy.com ServerAlias api.xyzzy.com RailsEnv production DocumentRoot /home/webby/rails/current/public &lt;/VirtualHost&gt; &lt;VirtualHost *:80&gt; ServerAlias * &lt;Directory /usr/local/xyzzy/webapps/wwwroot &gt; Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all &lt;/Directory&gt; DocumentRoot /usr/local/xyzzy/webapps/wwwroot &lt;/VirtualHost&gt; </code></pre> <p><strong>UPDATE:</strong></p> <p>The configuration below appears to be working as expected now. This is based on @Winfield's answer.</p> <p>It seems my testing might have been in error. My browser (Chrome) might have been auto-completing the address I was typing in with an https (not http) prefix. Unfortunately I didn't notice this anomaly until after trying dozens of permutations of configurations so it's hard to tell what the final proper resolution was. I should have been using curl on the command line for a more reliable test rather than typing in the browser bar.</p> <pre><code>&lt;VirtualHost *:80&gt; &lt;Directory /usr/local/xyzzy/webapps/wwwroot &gt; Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all &lt;/Directory&gt; DocumentRoot /usr/local/xyzzy/webapps/wwwroot &lt;/VirtualHost&gt; &lt;VirtualHost *:80&gt; ServerAlias api.xyzzy.com RailsEnv production DocumentRoot /home/webby/rails/current/public &lt;/VirtualHost&gt; </code></pre>
 

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