Is there a way to if/else a rewrite in Apache htaccess?

Viewed 19504

I want to create the following structure in my .htaccess file:

If (SITE A DOMAIN or SITE A SUBDOMAIN) {  
   Rewrite this specific way ->  /index.php/$1 
} else {
   Rewrite this specific way ->  /directory/www/index.php/$1
}

I have my current code below, but it's throwing 500s with my Apache error logs whining about:

[error] [client ::1] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary., referer:

What am I doing wrong? Thanks!

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|blog)

RewriteCond %{HTTP_HOST} ^subdomain\.example\.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^ example\.com$
RewriteRule .? - [S=1]
RewriteRule ^(.*)$ /directory/www/index.php/$1 [L]
RewriteRule .? - [S=1]
RewriteRule ^(.*)$ /index.php/$1 [L]
1 Answers
Related