I am trying to redirect all traffic into a subdomain.
http://www.example.com, example.com, sub.othersite.com
all rewrite to sub.othersite.com
It works great. Now I need to exclude a single URL from redirecting to the subdomain
So if http://www.example.com/THE/URI comes in, I want mod rewrite to ignore the subdomain rewrite and send it to the main domain.
Seems simple enough but I can’t get it to work because I have an additional rewrite that makes sure all the domains (there are a couple parked ones as well) funnel into a single domain to deliver the content.
I have a few other rewrite conditions. They are all listed here. If someone could point me in the right direction – I need to basically do this:
IF incoming request is for /THE/URI
then go to http://www.example.com/THE/URI
otherwise
rewrite to sub.othersite.com
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
# ignore system folder
RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(client/*)
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ index.php?/$1 [L]
# if it is the SPECIAL URI redirect and EXIT
RewriteCond $1 !^(/THE/URI)
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/THE/URI [L]
#catch all other traffic
RewriteCond %{HTTP_HOST} !^example.anothersite.com$
RewriteRule ^(.*)$ http://example.anothersite.us/$1
</IfModule>
Solved.
The answer was simple. I just needed to exclude both the URI and the QUERY_STRING from the final rewrite, since the top half of the rewrite appends the URL with a query string.
In order for my application to work, I still needed the initial rewrite (take any URI and internally map it to index.php?URI)
Final code: