title: Wildcard domain and links to pages in site root
body: <p>I have a wildcard subdomain (ServerAlias *.mydomain.com) to catch all subdomains requests and redirecting them to the home page while keeping the "fake" URL in the browser and passing the subdomain (city name) as a URL parameter</p>
  
  <p>.htaccess in the subdomain folder:</p>
  
  <pre><code>&lt;IfModule mod_rewrite.c&gt;
   Options +FollowSymLinks
   RewriteEngine On
   RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.(.*)$ [NC]
   RewriteRule ^(.*)$ http://%2.%3/index.php?city=%1 [P,L]
  &lt;/IfModule&gt;
  </code></pre>
  
  <p>The problem: there is a menu with some links in every page (register.php, login.php, contact.php) and if you select any of them while being in one subdomain, the request (city.mydomain.com/login.php for example) is captured by the condition/rule</p>
  
  <p>I guess I need to add a second set of condition(s)/rule but after some tests can't find the right one. I added this before the one already working: </p>
  
  <pre><code> RewriteCond %{HTTP_HOST} ^(.*)\.(.*)\.(.*)$ [NC]
   RewriteCond %{REQUEST_URI} ^/(.*)\.php$ [NC]
   RewriteRule ^(.*)$ http://%2.%3/%4 [P,L]
  </code></pre>
  
  <p>receiving the error:</p>
  
  <p>Bad Gateway!
  The proxy server received an invalid response from an upstream server.
  The proxy server could not handle the request GET /register.php.</p>
  
  <p>Reason: DNS lookup failure for:</p>
  
  <p>If you think this is a server error, please contact the webmaster.</p>
  
  <p>Error 502
  city.domaim.com</p>
  
  <p>CentOS 5
  Parallels Small Business Panel 10.2.0</p>
  
  <p>Thanks in advance</p>