w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Htaccess rule to ignore folder only if it's NOT a specific host

I added the following to the .htaccess in my /blog/ directory to fix this.

#rewrite back to root index if not local dev or live main host
RewriteCond %{HTTP_HOST} !^www.domain.com [NC]
RewriteCond %{HTTP_HOST} !^dev.local.domain.com [NC]
RewriteRule .* /index.php/$0 [PT,L]

The draw back is of course that 2 htaccess files have to be read for each request in this category which isn't ideal but it works and it's not a primary function of the application.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.