locked
Rule to redirect one domain to another? RRS feed

  • Question

  • User-1123536643 posted

    So, my appologies as I am new to this forum and the URL Rewrite module.  I have had success rewriting within the same site, but I wanted to create a rule that would redirect the user's browser from the old domain name to the new domain name. 

    http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/  <-- Tip #3  I can't seem to get this to work correctly. 

    I want to redirect the user from oldDomain.com --> newdomain.com.  How do I do that correctly?  I thought that this code would work, but it doesn't appear to as I expect or as the other rules in my web.config.

    <rule name="Canonical Host Name" stopProcessing="true">
      <match url="(.*)" />
      <conditions>
        <add input="{HTTP_HOST}" negate="true" pattern="^anitkb\.com$" />
      </conditions>
      <action type="Redirect" url="http://itgeared.com/{R:1}}" redirectType="Permanent" />
    </rule>

    Question #2-- When I get this rule to work, do I change the stopProcessing="true" to stopProcessing="false" since I have other rules under this one that may apply in the case of http://oldDomain/page.html that needs to go to http://newDomain.differentpage.aspx?

    Wednesday, October 26, 2011 3:23 PM

Answers

  • User-1637866776 posted
    Do you want to redirect from anitkb.com to itgeared.com? If yes, then try removing negate="true". Also, there is no need to change the rule to stopProcessing="false" because this is a redirection rule, so other rules will not be executed anyway if this rule fires.
    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, October 26, 2011 7:02 PM

All replies

  • User-1637866776 posted
    Do you want to redirect from anitkb.com to itgeared.com? If yes, then try removing negate="true". Also, there is no need to change the rule to stopProcessing="false" because this is a redirection rule, so other rules will not be executed anyway if this rule fires.
    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, October 26, 2011 7:02 PM
  • User-1123536643 posted
    Thank you for your help. That did the trick. I have been reading all of your articles about URL Rewrite. I am understanding it much better now.
    Friday, October 28, 2011 10:18 PM
  • User1592497500 posted
    Do you want to redirect from anitkb.com to itgeared.com? If yes, then try removing negate="true". Also, there is no need to change the rule to stopProcessing="false" because this is a redirection rule, so other rules will not be executed anyway if this rule fires.
    Actually, I have similar question. and my requirement is "rewrite from old domain to new domain". For example, I want to rewrite request from "www.old.com" to "www.new.com", and handler in "www.new.com " will request cookie whose domain name is "new.com", when original request is from "www.old.com", how can I get these cookies generated by "www.new.com". As we all know, it is prevented by cookie nature. Can you give me some ideas?
    Thursday, May 10, 2012 3:25 AM