title: RewriteCond in .htaccess to search robots.txt and sitemap.xml in domain subfolder
body: <p>I would like to write a rewriterule to search for robots.txt and sitemap.xml files in a subfolder that match the domain name with or without the www. Let’s take an example:</p>
  
  <ul>
  <li>I have domains aaa.com, bbb.com and ccc.com</li>
  <li>They are all installed in the same root folder %{DOCUMENT_ROOT}</li>
  <li>They can be accessed with or without the www.</li>
  </ul>
  
  <p>If someone is trying to access the <a href="http://aaa.com/robots.txt" rel="nofollow">http://aaa.com/robots.txt</a> file, I would like to perform the following:</p>
  
  <p>If the files requested is robots.txt {</p>
  
  <ul>
  <li>If there is a file that matches a subfolder %{DOCUMENT_ROOT}/aaa.com/robots.txt (give this file and stop) *1</li>
  <li>ElseIf there is a file that matches a subfolder
  %{DOCUMENT_ROOT}/www.aaa.com/robots.txt (give this file and stop) *2</li>
  <li>Else give the file %{DOCUMENT_ROOT}/robots.txt *3</li>
  </ul>
  
  <p>}</p>
  
  <p>I don’t want to hardcode the domain names; I tried to take them from the request but I wasn’t able to check the conditions *2 and *3:</p>
  
  <pre><code>RewriteCond %{REQUEST_URI} ^/robots.txt$
  RewriteRule ^robots\.txt$ /www\.%{HTTP_HOST}/robots\.txt [L]
  RewriteCond %{REQUEST_URI} ^/sitemap.xml$
  RewriteRule ^sitemap\.xml$ /www\.%{HTTP_HOST}/sitemap\.xml [L]
  </code></pre>
  
  <p>Thank you for your help !</p>