asp.net-mvciisisapi-rewritehelicontechisapi-redirect

Using HELICON ISAPI Rewrite & ASP.Net MVC - Url Redirection


I am using IIS and HELICON ISAPI rewrite.

My Requirement: Redirect 1 market specific sites to new domain.

ex: www.example.com/anz -> www.example2.com/anz (should redirect)
www.example.com/deu -> www.example.com/deu (should not redirect)

I tried:

RewriteCond %{HTTP_HOST} ^example.com [NC]

RewriteRule ^(.*)$ https://example2.com/$1 [L,R=302]

It redirects, but both the markets.

and again with

RewriteCond %{HTTP_HOST} ^example.com/anz [NC]

RewriteRule ^(.*)$ www.example2.com/anz/$1 [L,R=302]

failed to redirect.

and again with escape sequence character

RewriteCond %{HTTP_HOST} ^example.com\/anz [NC]

RewriteRule ^(.*)$ https://example2.com/anz/$1 [L,R=302]

failed to redirect.

Please help me.


Solution

  • Please try:

    RewriteCond %{HTTP_HOST} ^(www\.)?example.com [NC]    
    RewriteRule ^/?(anz.*)$ https\://www.example2.com/$1 [L,R=302]