mod_rewrite: check if isn't a certain domain

Posted by weingage on Stack Overflow See other posts from Stack Overflow or by weingage
Published on 2013-06-30T04:37:00Z Indexed on 2013/06/30 16:21 UTC
Read the original article Hit count: 151

Filed under:
|
|

I'm migrating some code from a working web app, but can't get it to work on the new server. Everything seems to be configured correctly, but I'm getting internal redirect limit errors in Apache2. Here are my rewrites and explanation

This WORKS - any subdomains that aren't cdn. or manage. should be redirected to u.php

RewriteCond %{HTTP_HOST} ^(^.*)\.mediasprk\.com$ [NC]
RewriteCond ^(.*)$ !^(cdn|manage)$
RewriteCond %{REQUEST_URI} !\.(png|gif|jpg)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ u.php?uri=$1&hostName=%{HTTP_HOST}

This is no longer working. Goal here is to handle CName pointing. So if it's not my app domain (mediasprk.com), then handle it by sending it to u.php.

RewriteCond %{HTTP_HOST} !^mediasprk\.com$ [NC]
RewriteCond %{REQUEST_URI) !\.(png|gif|jpg)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ u.php?uri=$1&hostName=%{HTTP_HOST}

Can anyone see the issue here in the second block that would cause the redirect limit errors? Maybe something wrong in the rewrites? Thanks.

© Stack Overflow or respective owner

Related posts about apache

Related posts about .htaccess