Modify existing .htaccess so that it ignores subdomains
<p>I have the following .htaccess file in place, and whilst I know it is nowhere near optimal (and probably a bit cringeworthy) - it just works.</p>

<pre><code># Prevents public viewing of .htaccess file
&lt;Files .htaccess&gt;
order allow,deny
deny from all
&lt;/Files&gt;

# Custom 404 page
ErrorDocument 404 https://www.domain.com/404/

# Turn on rewriting and set rewriting base
RewriteEngine On
RewriteBase /

# Force WWW
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} ^([^.]+)\.([a-z]{2,4})$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^ http%1://www.%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# Force WWW and HTTPS
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=301,L]

# Remove .php extension
RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9)/(asc|desc) $1.php?location=$2&amp;bedrooms=$3&amp;sort-by=$4
RewriteRule ^(properties)/(all|location1|location2|location3)/(all|1|2|3|4|5|6|7|8|9) $1.php?location=$2&amp;bedrooms=$3
RewriteRule ^(properties)/(all|location1|location2|location3) $1.php?location=$2
RewriteRule ^(view-property)/(.*)/(print-view) $1.php?id=$2&amp;print=true
RewriteRule ^(view-property)/(.*)/ $1.php?id=$2
RewriteRule ^(.*)/$ $1.php
</code></pre>

<p>Our new website is now ready to be pushed to our newly created staging environment for testing. In this instance it would be <code>staging.domain.com</code> but we're having problems actually accessing this staging URL.</p>

<p>EDIT - Just to clarify, the problem is that accessing <code>staging.domain.com</code> redirects to <code>https://www.domain.com</code>.</p>

<p>We believe the problem is caused by the rewrite rules we have in place above. I have researched a few possible solutions include adding additional conditions to the existing rewrite rules such as:</p>

<p><code>RewriteCond %{HTTP_HOST} !^staging\.domain\.com</code></p>

<p>or adding a new condition/rule such as:</p>

<pre><code>RewriteCond %{HTTP_HOST} ^staging\.domain\.com [NC]
RewriteRule ^(.*) - [L]
</code></pre>

<p>but unfortunately none of these have worked. Working with <code>.htaccess</code> files is really not my strong suit, so if anyone could offer any assistance that would be great.</p>

<p>P.S. The new site is powered by Laravel 5.3 so I will be getting rid of the terrible attempt at rewriting rules (those at the bottom) when we go live!</p>