Sunday, 28 September 2014

Redirect aspx website in IIS using C# code.

My Scenario:

  I want to access my domain www.myexample.com/in, when I try to browse my sub domain site  www.myexample.in.

Solution:

    I tried the below  code in my default.aspx page,

<%@ Page language="c#" Codebehind="default.aspx.cs" AutoEventWireup="True" Inherits="umbraco.UmbracoDefault" trace="true" validateRequest="false" %>
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.myexample\.in
RewriteRule (.*) http://www.myexample.com/in/$1 [R=301,L]

The direction is works fine.

No comments:

Post a Comment