3

I'm trying to redirect all urls from one domain to another but one (kind of). This is the htaccess I have to redirect all keeping the same url except of the domain (for example domain.com/something goes to domain2.com/something).

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^(.*)$ "http://domain2.com/$1" [R=301,L]

What I want to know is how to redirect all except if the url is domain.com/validation/*

/validation/ is not a subfolder and it has to be the next part of the url after the domain (domain.com/something/validation can redirect, and domain.com/validation/something can't).

I tried a lot of options but none worked :(

I hope is enough information.

anubhava
  • 761,203
  • 64
  • 569
  • 643
rmiquel
  • 55
  • 1
  • 5

1 Answers1

4

You can exclude it in RewriteRule itself:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule !^validation http://domain2.com%{REQUEST_URI} [NE,NC,R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643