Search code examples
.htaccessmod-rewritetld

RewriteCond: Ignoring a top level domain


I have the following rewrite in my .htaccess file:

RewriteCond %{HTTP_HOST} ^sub.domain.lc(.*)
RewriteRule $(.*) app.php$1 [NC,L,QSA]

I am using sub.domain.lc to develop on my local machine, but when my site goes live it uses another top level domain: sub.domain.com.

How do I create a RewriteCond that ignores the top level domain? It should rewrite both sub.domain.lc and sub.domain.com to app.php.


Solution

  • You can do it this way

    RewriteCond %{HTTP_HOST} ^sub\.domain\.(?:lc|com)$ [NC]
    RewriteRule ^(.*)$ /app.php/$1 [NC,L,QSA]