How to redirect url using UrlRewriter.Nethttp://forums.asp.net/t/1805227.aspx/1?How+to+redirect+url+using+UrlRewriter+NetFri, 25 May 2012 08:47:24 -040018052274987562http://forums.asp.net/p/1805227/4987562.aspx/1?How+to+redirect+url+using+UrlRewriter+NetHow to redirect url using UrlRewriter.Net <p>Hi,</p> <p>I am pretty new to URL Rewriting concept. In my project I need to display the url</p> <p>say for eg. localhost/default.aspx as localhost/en/default.</p> <p>Also, if the url is like&nbsp;localhost/en/default.aspx, it should redirect as&nbsp;localhost/en/default.</p> <p>If the language selected is Chinese, the url will be localhost/zh-CHS/default-zh.aspx .</p> <p>It should be rewritten as localhost/zh-CHS/default-zh.</p> <p>Also, if url in chinese is&nbsp;localhost/about-zh.aspx it should be displayed as&nbsp;localhost/zh-CHS/about-zh.</p> <p>The default language is English.</p> <p>I am trying to achieve this with UrlRewriter.Net (<em>Intelligencia.UrlRewriter</em>)</p> <p>Can anyone please tell how to write the rules in the web.config to achieve this?</p> <p>I am doing this project in .Net 4.0 .&nbsp;</p> <p>&nbsp;Please help.</p> <p>Thanks,</p> <p>Surya.</p> 2012-05-18T18:51:53-04:004990034http://forums.asp.net/p/1805227/4990034.aspx/1?Re+How+to+redirect+url+using+UrlRewriter+NetRe: How to redirect url using UrlRewriter.Net <p>Hi</p> <p>MSDN is your friends</p> <p><a href="http://msdn.microsoft.com/en-us/library/ms972974.aspx#urlrewriting_topic7">http://msdn.microsoft.com/en-us/library/ms972974.aspx#urlrewriting_topic7</a></p> <p>And&nbsp;</p> <p><a href="http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET">http://www.codeproject.com/Articles/2538/URL-Rewriting-with-ASP-NET</a></p> <p>Also you need some regular expression knowledge:</p> <p><a href="http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet">http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet</a></p> <p>Hope it helpful.</p> 2012-05-21T11:25:46-04:004992450http://forums.asp.net/p/1805227/4992450.aspx/1?Re+How+to+redirect+url+using+UrlRewriter+NetRe: How to redirect url using UrlRewriter.Net <p>Hi,</p> <p>Can anyone please help. I don't know how to write rules in web.config to achieve extensionless urls</p> 2012-05-22T16:19:41-04:004993327http://forums.asp.net/p/1805227/4993327.aspx/1?Re+How+to+redirect+url+using+UrlRewriter+NetRe: How to redirect url using UrlRewriter.Net <p>Hi</p> <p>Have you readed the link I gave you?</p> <p>First you need to download the URLRewriter.</p> <p><a href="http://download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/MSDNURLRewriting.msi" style="">http://download.microsoft.com/download/0/4/6/0463611e-a3f9-490d-a08c-877a83b797cf/MSDNURLRewriting.msi</a></p> <p>Then add code like this in your web.config</p> <pre class="prettyprint">&lt;configuration&gt; &lt;configSections&gt; &lt;section name=&quot;RewriterConfig&quot; type=&quot;URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter&quot;/&gt; &lt;/configSections&gt; &lt;RewriterConfig&gt; &lt;Rules&gt; &lt;RewriterRule&gt; &lt;LookFor&gt;/ShowQueryString_post/(\d{4})/(\d{2})/(\d{2})/(\d{1})&lt;/LookFor&gt; &lt;SendTo&gt;~/ShowQueryString_post.aspx?Year=$1&amp;amp;Month=$2&amp;amp;Day=$3&amp;amp;id=$4&lt;/SendTo&gt; &lt;/RewriterRule&gt; &lt;/Rules&gt; &lt;/RewriterConfig&gt; &lt;system.web&gt;</pre> <p><br> In my code LookFor is a regular expression(That's why I said you need to know the regular expression).</p> <p>So when I input [domainname]/ShowQueryString_post/2012/05/02/1</p> <p>It will convert to [domainname]/ShowQueryString_post.aspx?Year=2012&amp;Month=05&amp;Day=02id=1</p> <p>Hope you read those link first, and then post threads with some specific problem.</p> <p>Hope it helpful.</p> <p>&nbsp;</p> 2012-05-23T07:46:09-04:004993426http://forums.asp.net/p/1805227/4993426.aspx/1?Re+How+to+redirect+url+using+UrlRewriter+NetRe: How to redirect url using UrlRewriter.Net <p>Hi,</p> <p>I am trying with urlrewriter.net</p> <p>For that I added a reference for&nbsp;Intelligencia.UrlRewriter dll in my project.</p> <p>Then in web.config added these sections.</p> <p>&lt;configSections&gt;</p> <p>&lt;section name=&quot;rewriter&quot; requirePermission=&quot;false&quot; type=&quot;Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter&quot; /&gt;</p> <p>&lt;/configSections&gt;</p> <p>&lt;httpModules&gt;</p> <p>&lt;add name=&quot;UrlRewriter&quot; type=&quot;Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter&quot; /&gt;<br> &lt;/httpModules&gt;</p> <p></p> <p>&lt;system.webServer&gt;<br> &lt;modules runAllManagedModulesForAllRequests=&quot;true&quot;&gt;<br> &lt;add name=&quot;UrlRewriter&quot; type=&quot;Intelligencia.UrlRewriter.RewriterHttpModule&quot; /&gt;<br> &lt;/modules&gt;<br> &lt;/system.webServer&gt;<br> &lt;rewriter&gt;<br> &nbsp; &nbsp;&nbsp;<br> &lt;/rewriter&gt;</p> <p></p> <p>I don't know how to write the rules in rewrite section.</p> 2012-05-23T08:45:33-04:004997032http://forums.asp.net/p/1805227/4997032.aspx/1?Re+How+to+redirect+url+using+UrlRewriter+NetRe: How to redirect url using UrlRewriter.Net <p>Hi</p> <p>You can refer to this link:<a href="http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx">http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx</a></p> <p>&lt;rewrite url=&quot;~/products/(.&#43;).aspx&quot; to=&quot;~/products.aspx?category=&#36;1&quot; /&gt;</p> <p>Can you understand this line?</p> <p>(.&#43;) this is a Regulary expression.</p> <p>I had post the link before.</p> <p>This line mean when you get ~/products/<em>[anypagename]</em>.aspx it will convert to ~/products.aspx?category=<em>[anypagename] </em></p> <p><em></em>Here is some tutorial.</p> <p><a href="http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html">http://dotnetguts.blogspot.com/2008/07/url-rewriting-with-urlrewriternet.html</a></p> <p>I think you just can't understand how does the Regular expression work.</p> <p>I suggest you download this open source URL write module, and try to understand it first.</p> <p><a href="http://urlrewriter.net/index.php/download">http://urlrewriter.net/index.php/download</a></p> <p>&nbsp;</p> <p lang="zh-CN" style="margin:0in; font-family:Calibri; font-size:11pt"><em>This response contains links reference to a third party World Wide Web site. Microsoft is providing this information as a convenience to you.Microsoft does not control these sites and has not tested any software or information found on these sites; therefore, Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there.There are inherent dangers in the use of any software found on the Internet, and Microsoft cautions you to make sure that you completely understand the risk before retrieving any software from the Internet.</em></p> <p>&nbsp;</p> 2012-05-25T08:47:24-04:00