You must Sign In to post a response.
  • Category: ASP.NET

    Multiple redirect to single page in ASP.NET

    HI All

    Please check my rewrite rule pasted below which working in given case . but i need to redirect many urls in a1.mydomain.com to http://www.newdomain.com/brand/static1.html.(mutilple pages to same page)

    like this for a1.mydomain.com

    i tried by adding one more input
    <add input="{HTTP_HOST}" pattern="^a1.mydomain.com?act=order$" />
    but its not working . How to do this

    <rewrite>
    <rules>


    <rule name="a1" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^a1.mydomain.com$" />
    </conditions>
    <action type="Redirect" url="http://www.newdomain.com/brand/static1.html" />
    </rule>


    <rule name="a2" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
    <add input="{HTTP_HOST}" pattern="^a2.mydomain.com$" />
    </conditions>
    <action type="Redirect" url="http://www.newdomain.com/brand/static2.html" />
    </rule>
    </rules>
    Thanks in Advance
  • #766628
    Hi

    we canot multiple Redirection . can you share more why you need multiple redirection . you can try this code



    In the code write in your Page1.aspx

    1.Response.Redirect("Default.aspx");

    In the code write in your Default.aspx in Pagelaod Event.

    2.Response.Redirect("Page2.aspx");


    In the code write in your Page2.aspx in Pagelaod Event.

    3.Response.Redirect("Page3.aspx");

    Or
    4.Server.Transfer("Page1.aspx");


    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #766629
    Hi,

    For Redirecting the control from one page to another page in .net you can use
    Response.Redirect() and Server.Transfer().. Both will be used to transfer from one page to another page.
    Other wise, if you not comfortable to use these control means kindly use the following JavaScript for transferring from one page to another. you can use either the separate JS file or Design itself.
    <html>
    <head>

    <script type="text/javascript">
    <!--
    function Redirect() {
    window.location="http://www.tutorialspoint.com";
    }
    //-->
    </script>

    </head>

    <body>
    <p>Click the following button, you will be redirected to home page.</p>

    <form>
    <input type="button" value="Redirect Me" onclick="Redirect();" />
    </form>

    </body>
    </html>

  • #766630
    Hi

    you can use the following Links for your reference too.
    1.http://www.c-sharpcorner.com/UploadFile/0c1bb2/response-redirect-true-and-response-redirect-false-in-asp-ne/
    2.https://www.sitepoint.com/community/t/multiple-forms-on-one-aspx-page/4101/6
    3.http://www.tutorialspoint.com/javascript/javascript_page_redirect.htm

    Regards,
    Karunanidhi.K

  • #766635
    Hi,

    Have you got any error while performing multiple URL rewrites?

    If yes, please share the error details, otherwise please use the below sample for URL Rewrites.

    <rule name="rule1" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTPS}" pattern="^OFF$" />
    <add input="{HTTP_HOST}" pattern="domain1\.com$" />
    </conditions>
    <action type="Redirect" url="URL1" />
    </rule>
    <rule name="rule2" stopProcessing="true">
    <match url=".*" />
    <conditions>
    <add input="{HTTPS}" pattern="^OFF$" />
    <add input="{HTTP_HOST}" pattern="domain2\.com$" />
    </conditions>
    <action type="Redirect" url="URL2" />
    </rule>


    For more details please refer below link http://jasonwatmore.com/post/2012/08/16/IIS-URL-Rewrite-Redirect-multiple-domains-to-one-and-http-to-https-with-a-single-rule.aspx

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #766650
    Better test the pattern from IIS itself and see if it works. If you are new to this topic please refer below article: http://www.iis.net/learn/extensions/url-rewrite-module/testing-rewrite-rule-patterns

    Also

    http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module


    Regards,
    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM


Sign In to post your comments