Sunday, 15 April 2012

apache - Mod rewrite to reidrect all traffic to different domain, except for set list of folders -



apache - Mod rewrite to reidrect all traffic to different domain, except for set list of folders -

we gradually moving clients site new scheme & domain name. in meantime need both sites live - sharing bits of same domain.

i have pointed primary domain new server - www.newserver.org

on server need apache redirect requests not in list of allowable folders old server - living on: www.oldserver.org (preserving path after domain).

i need new server accessible without redirecting when accessed via it's ip address.

my best effort @ apache configuration:

documentroot /var/www rewriteengine on rewritecond %{request_uri} !^/landing/ rewritecond %{request_uri} !^/admin/ rewritecond %{request_uri} !^/user/ rewritecond %{request_uri} !^/sites/ rewritecond %{request_uri} !^/scripts/ rewritecond %{http_host} ^www.newserver.org$ rewriterule ^(.*) http://www.oldserver.org/$1 [nc,r=301,l]

can assist right rewritecond & ordering? @ moment requests - specified folders redirecting.

---- tried:

rewriteengine on rewritecond %{http_host} ^www.newserver.org$ rewritecond %{request_uri} !^(landing|admin|user|sites|scripts) [nc] rewriterule ^(.*) http://www.oldserver.org/$1 [nc,r=301,l]

suggested on forum still redirecting requests - folders

try this:

rewriteengine on rewritecond %{http_host} ^www.newserver.org$ rewriterule ^(?!(landing|admin|user|sites|scripts)/)(\w+/.*)$ http://www.oldserver.org/$2 [nc,r=301,l]

apache mod-rewrite configuration

No comments:

Post a Comment