locked
ReWrite Rule not working properly on some pages ! RRS feed

  • Question

  • User665347573 posted
    Hi, I have two pages in my site, category.aspx and subcategory.aspx and I have created UserFriendly URL rules using URL Rewrite2 as given below. For first page: 'http://www.mysite.com/category.aspx?CCode=womens-wear' became 'http://www.mysite.com/womens-wear', this pages is working correctly from all links. For Second Page: 'http://www.mysite.com/subcategory.aspx?CatCode=womens-wear&ScCode=sarees' became 'http://www.mysite.com/womens-wear/sarees', when I click subcategory link from category page, its working fine and I am getting subcategory page with user friendly URL. but once I reach subcategory page, if I click any link in subcategory page, for example same 'sarees' link in subcategory page, I am getting URL like this - 'http://www.mysite.com/womens-wear/subcategory.aspx?CatCode=womens-wear&ScCode=sarees', means the category code 'womens-wear' coming twice in this url. Thanks in advance, waiting for the your help... Regards Joseph
    Saturday, June 25, 2011 2:53 AM

Answers

  • User-176674611 posted

    Hi,

    The issue is caused by you didn't add the prefix "Category" in your outbound rule. Also I suggest you change your pattern a bit, for your pattern will only pass evaluation for absolute urls. The rule will look like:


    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1" >
      <match filterByTags="A, Form, Img" pattern="^(.*)category\.aspx\?CCode=([^=&amp;]+)$" />
      <action type="Rewrite" value="{R:1}/Category/{R:2}/" />
    </rule>

    Thanks.

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, June 30, 2011 9:55 PM

All replies

  • User-176674611 posted

    Hi,

    What does the link url in your page look like? Could you please also post the rules you use?

    Thanks.

     

    Monday, June 27, 2011 5:25 AM
  • User665347573 posted

    I have two pages in my ASP.NET site, category.aspx - 'http://www.mysite.com/category.aspx?CCode=womens-wear' 

    and subcategory.aspx -  'http://www.mysite.com/subcategory.aspx?ScCode=sarees'

    I have created UserFriendly URL rules using URL Rewrite2, autogenerated script in web.config as given below.

                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^category\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>


                    <rule name="RedirectUserFriendlyURL2"  stopProcessing="true">
                        <match url="^subcategory\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^ScCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>

    in this situation, category.aspx is working fine with friendly url like 'http://www.mysite.com/womens-wear' , but subcategory.aspx is giving error. If I disable any one rule other page will work fine. That means these two rules together is not working.

    Monday, June 27, 2011 8:01 AM
  • User-176674611 posted

    Hi,

    The redirect rules are correct. However, according to your description, you should have another 2 rewrite rules that rewrite the friendly url back to category/subcategory.aspx, could you also please post that 2 rules here? I guess the issue is caused by conflict of the pattern of that 2 rewrite rules, that can explain why one page works when you disable rules set for another page. To determine this, you can enable failed request tracing to see the detailed rewriting process:

    Using Failed Request Tracing to Trace Rewrite Rules
    http://learn.iis.net/page.aspx/467/using-failed-request-tracing-to-trace-rewrite-rules

    Thanks.

    Monday, June 27, 2011 10:56 PM
  • User665347573 posted

    Hi

    I have two pages in my ASP.NET site, category.aspx - 'http://www.mysite.com/category.aspx?CCode=womens-wear' and subcategory.aspx -  'http://www.mysite.com/subcategory.aspx?ScCode=sarees'

    I have created UserFriendly URL rules using URL Rewrite2, autogenerated script in web.config as given below. In this situation, category.aspx is working fine with friendly url like 'http://www.mysite.com/womens-wear' , but subcategory.aspx is giving error. If I disable any one rule other page will work fine. That means these two rules together is not working. I working on this last two days, no hope, please help me....

    script from web.config

             <rewrite>
                <outboundRules>
                    <clear />
                    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)category\.aspx\?CCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <rule name="OutboundRewriteUserFriendlyURL2" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)subcategory\.aspx\?ScCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
                <rules>
                    <clear />
                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^category\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                        <match url="^([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="category.aspx?CCode={R:1}" />
                    </rule>
                    <rule name="RedirectUserFriendlyURL2" enabled="false" patternSyntax="ECMAScript" stopProcessing="true">
                        <match url="^subcategory\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^ScCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL2" stopProcessing="true">
                        <match url="^([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="subcategory.aspx?ScCode={R:1}" />
                    </rule>
                </rules>
            </rewrite>

    Tuesday, June 28, 2011 2:38 AM
  • User-176674611 posted

    This made the issue clear. You use same pattern for these 2 rewrite rules, so rewrite module will always process the first rewrite rule(RewriteUserFriendlyURL1 in this case) for the redirected requests. You need to use different patterns to filter the requests so that the module will know whether the requests should be rewritten as category.aspx or subcategory.aspx properly.

    If you have trouble with generating the patterns, you can describe the difference between the request urls that should be rewritten as category.aspx and the request urls that should be rewritten as subcategory.aspx. With these information, we can generate the pattern that work for you.

    Thanks.

     

    Tuesday, June 28, 2011 3:06 AM
  • User665347573 posted

    Hi,

    Thank you very much for the quick reply. Actually the above script is generated automatically from URL Rewrite 2 and I am not familiar with these patterns. So could u please give me the script for the below given requirement. Thanks in advance.

    I have two pages

    1. category.aspx

                 Orginal Url -  http://www.mysite.com/category.aspx?CCode=womens-wear

                 User Friendly Url should be like - http://www.mysite.com/womens-wear

     2. subcategory.aspx

                 Orginal Url -  http://www.mysite.com/subcategory.aspx?ScCode=sarees

                 User Friendly Url should be like - http://www.mysite.com/sarees 

     

    Tuesday, June 28, 2011 3:24 AM
  • User-176674611 posted

    Based on the example, I could only hardcode the pattern. Like "^womens-wear/?$ for RewriteUserFriendlyURL1 and "^sarees/?$" for RewriteUserFriendlyURL2. However, this will make the rules work only for your example. To make the rules work properly for all the requests, we still need some common difference for these two kinds of requests.

    It will be good to hear if you can tell something like that, for example, all CCode should contain an "A" and all ScCode should contain a "B". Without the common distinguishing feature, we cannot generate the patterns properly.

    Thanks.

    Tuesday, June 28, 2011 4:15 AM
  • User665347573 posted

    Hi,

    Thank you very much for the reply. Could you please put the given example patterns("^womens-wear/?$" and  "^sarees/?$") in the below given script in PROPER place and please send it to me. so that I can start play with that and I can find out a solution.

              <rewrite>
                <outboundRules>
                    <clear />
                    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)category\.aspx\?CCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <rule name="OutboundRewriteUserFriendlyURL2" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)subcategory\.aspx\?ScCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
                <rules>
                    <clear />
                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^category\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                        <match url="^([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="category.aspx?CCode={R:1}" />
                    </rule>
                    <rule name="RedirectUserFriendlyURL2" stopProcessing="true">
                        <match url="^subcategory\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^ScCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL2" stopProcessing="true">
                        <match url="^([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="subcategory.aspx?ScCode={R:1}" />
                    </rule>
                </rules>
            </rewrite>

    Tuesday, June 28, 2011 4:25 AM
  • User-176674611 posted

            <rewrite>
                <outboundRules>
                    <clear />
                    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)category\.aspx\?CCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <rule name="OutboundRewriteUserFriendlyURL2" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)subcategory\.aspx\?ScCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
                <rules>
                    <clear />
                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^category\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                        <match url="^(womens-wear)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="category.aspx?CCode={R:1}" />
                    </rule>
                    <rule name="RedirectUserFriendlyURL2" stopProcessing="true">
                        <match url="^subcategory\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^ScCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL2" stopProcessing="true">
                        <match url="^(sarees)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="subcategory.aspx?ScCode={R:1}" />
                    </rule>
                </rules>
            </rewrite>

    As I said, this will only work for your example requests. Any further updates, feel free to post here.

    Thanks.

    Tuesday, June 28, 2011 4:33 AM
  • User665347573 posted

    Hi

    Thank you. As you said I can add a suffix '-category' with all my categories and prefix '-subcategory' with all subcategories. For example 'womerns-wear-category' for category and 'sarees-subcategory' for sub categories. but my user friendly url will looks like ' http://www.mysite.com/womens-wear-category' and  http://www.mysite.com/sarees-subcategory'.

    But, if you see the site http://www.bulkplaza.com , their urls not contain any prefix or sufix. Please click some items on their dropdown menu. Urls looks like http://www.bulkplaza.com/womens-wear.html, http://www.bulkplaza.com/womens-wear/bridal-saree.html, http://www.bulkplaza.com/womens-wear/bridal-saree/bridal-sensation.html etc.

    Could you please explain how to achieve this.

     

    Tuesday, June 28, 2011 5:12 AM
  • User665347573 posted

    Hi

    One more doubt, my urls are http://www.mysite.com/category.aspx?CCode=womens-wear and http://www.mysite.com/subcategory.aspx?ScCode=sarees

    in these, page name is different for both(category.aspx and subcategory.aspx), query string name is different (CCode and ScCode) for both and query string value also different, then why should I add a prefix/sufix with these again ?

    Could you please clear this for me..

    Tuesday, June 28, 2011 5:32 AM
  • User-176674611 posted

    Hi,

    The original requests are different. As you said, the request pages are different(category.aspx, subcategory.aspx) and the query string also different(CCode and ScCode).
    However, the friendly url(a new request) of these two kind of requests that you want to achieve are the same, both like http://www.mysite.com/CodeValue, where CodeValue is either the value of CCode or ScCode. In this case, we don't know whether the CodeValue is an CCode value or an ScCode value. That's why we should tell the common difference between these 2 kinds of urls.
    I hope this make it clear.

    Thanks.

     

    Tuesday, June 28, 2011 5:48 AM
  • User665347573 posted

    Hi

    If you see the site http://www.bulkplaza.com , their urls not contain any prefix or sufix. Please click some items on their dropdown menu. Urls looks like http://www.bulkplaza.com/womens-wear.html, http://www.bulkplaza.com/womens-wear/bridal-saree.html.

    I need to do is exactly same, let the first page is http://www.mysite.com/category.aspx?CCode=womens-wear  and second page is http://www.mysite.com/subcategory.aspx?CCode=womens-wear&ScCode=bridal-saree

    could you please make changes in below given script to achieve this.

     

    <rewrite>
                <outboundRules>
                    <clear />
                    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)category\.aspx\?CCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <rule name="OutboundRewriteUserFriendlyURL2" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)subcategory\.aspx\?ScCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}{R:2}/" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
                <rules>
                    <clear />
                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^category\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                        <match url="^([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="category.aspx?CCode={R:1}" />
                    </rule>
                    <rule name="RedirectUserFriendlyURL2" stopProcessing="true">
                        <match url="^subcategory\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^ScCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL2" stopProcessing="true">
                        <match url="^([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="subcategory.aspx?ScCode={R:1}" />
                    </rule>
                </rules>
            </rewrite>

    Tuesday, June 28, 2011 8:40 AM
  • User-176674611 posted

    Hi,

    I didn't see your post describing prefix/suffix that time, sorry for that, now it's clear.

    For "http://www.bulkplaza.com", I think we don't know what is/are the exactly page(s) for the requests. If it is one single page that handles all the requests, then url rewrite module could simply implement this. If multiple pages are at the back-end, like your situation, I think no module is smart enough to determine which is the proper page for the request without your letting it know the "rule"(difference).


    By referring to the secodn page, do you mean CCode and ScCode could exist at the same time in one request? Does this situation only happens in subcategory.aspx?

    Thanks.

     

    Tuesday, June 28, 2011 10:10 PM
  • User665347573 posted

    Hi,

    Thank you very much for the reply. Based on our discusion, I have made some changes in my scripts. Now it is as given below.

    Page 1 - category.aspx

    original url - http://www.indiafashiononline.com/category.aspx?CCode=womens-wear

    user friendly url - http://www.indiafashiononline.com/category/womens-wear

    Page 2 -subcategory.aspx

    original url - http://www.indiafashiononline.com/subcategory.aspx?CCode=womens-wear&ScCode=sarees

    user friendly url - http://www.indiafashiononline.com/subcategory/womens-wear/sarees

    and please see the script given below, now as you told before, in both patterns a unique value is there, like 'category' in first one and 'subcategory' in second one.


                <rules>
                    <clear />
                    <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
                        <match url="^category\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="category/{C:1}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
                        <match url="^category/([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="category.aspx?CCode={R:1}" />
                    </rule>
                    <rule name="RedirectUserFriendlyURL2" stopProcessing="true">
                        <match url="^subcategory\.aspx$" />
                        <conditions>
                            <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                            <add input="{QUERY_STRING}" pattern="^CatCode=([^=&amp;]+)&amp;ScCode=([^=&amp;]+)$" />
                        </conditions>
                        <action type="Redirect" url="subcategory/{C:1}/{C:2}" appendQueryString="false" />
                    </rule>
                    <rule name="RewriteUserFriendlyURL2" stopProcessing="true">
                        <match url="^subcategory/([^/]+)/([^/]+)/?$" />
                        <conditions>
                            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        </conditions>
                        <action type="Rewrite" url="subcategory.aspx?CatCode={R:1}&amp;ScCode={R:2}" />
                    </rule>
                </rules>
                <outboundRules>
                    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)category\.aspx\?CCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}category/{R:2}/" />
                    </rule>
                    <rule name="OutboundRewriteUserFriendlyURL2" preCondition="ResponseIsHtml1">
                        <match filterByTags="A, Form, Img" pattern="^(.*/)subcategory\.aspx\?CatCode=([^=&amp;]+)&amp;(?:amp;)?ScCode=([^=&amp;]+)$" />
                        <action type="Rewrite" value="{R:1}subcategory/{R:2}/{R:3}/" />
                    </rule>
                    <preConditions>
                        <preCondition name="ResponseIsHtml1">
                            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                        </preCondition>
                    </preConditions>
                </outboundRules>
            </rewrite> 

    But I am facing issues

    Step 1.

    When I place the mouse over WOMENS WEAR on top navigbar on my site  (http://www.indiafashiononline.com), in status bar I can see the link as given below, if I click the  link , its working fine and I am getting the url like http://www.indiafashiononline.com/category/womens-wear

    status bar - http://www.indiafashiononline.com/category.aspx?CCode=womens-wear

    Step 2. 

    but once I click the link, after that I place the mouse over the same WOMENS WEAR link, the status bar link will change as given below

    status bar - http://www.indiafashiononline.com/category/category.aspx?CCode=womens-wear

    and I am getting error when I click the same url.

    That means the word 'category' in the previous url repeating next time. I think the situation is clear to you, Do you think it is because of the OUTBOUND RULES ? All the link I have given are live, so that you can try with it. Please go through these and kindly help me to resove this issue.

     

    Wednesday, June 29, 2011 5:25 AM
  • User665347573 posted

    Hi,

    Still I am facing issues, Please help me somebody to resolve this. 

    I have one pages in my ASP.NET application. I am trying to implement User Fiendly URL using IIS URL ReWrite 2. But I am facing some issues.

     

    Request Details: 

    category.aspx
    original url - http://www.indiafashiononline.com/category.aspx?CCode=womens-wear
    user friendly url - http://www.indiafashiononline.com/category/womens-wear

    and please see the script given below,

    <rules>
         <clear />
         <rule name="RedirectUserFriendlyURL1" stopProcessing="true">
             <match url="^category\.aspx$" />
             <conditions>
                   <add input="{REQUEST_METHOD}" pattern="^POST$" negate="true" />
                   <add input="{QUERY_STRING}" pattern="^CCode=([^=&]+)$" />
             </conditions>
             <action type="Redirect" url="category/{C:1}" appendQueryString="false" />
         </rule>
         <rule name="RewriteUserFriendlyURL1" stopProcessing="true">
            <match url="^category/([^/]+)/?$" />
            <conditions>
               <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
               <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="category.aspx?CCode={R:1}" />
         </rule>
    </rules>
    <outboundRules>
        <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1">
              <match filterByTags="A, Form, Img" pattern="^(.*/)category\.aspx\?CCode=([^=&]+)$" />
             <action type="Rewrite" value="{R:1}category/{R:2}/" />
        </rule>
    <preConditions>
         <preCondition name="ResponseIsHtml1">
            <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
         </preCondition>
     </preConditions>
    </outboundRules>
    </rewrite>


    But I am facing issues
    Step 1.
    When I place the mouse over WOMENS WEAR on top navigbar on my site (http://www.indiafashiononline.com), in status bar I can see the link as given below, if I click the link , its working fine and I am getting the url like http://www.indiafashiononline.com/category/womens-wear
    status bar - http://www.indiafashiononline.com/category.aspx?CCode=womens-wear
    Step 2.
    but once I click the link, after that I place the mouse over the same WOMENS WEAR link, the status bar link will change as given below
    status bar - http://www.indiafashiononline.com/category/category.aspx?CCode=womens-wear
    and I am getting error when I click the same url.
    That means the word 'category' in the previous url repeating next time.
    means the string '/category' also added with 'www.indiafashiononline.com'. I think the situation is clear to you, Do you think it is because of some mistakes in OUTBOUND RULES ? All the link I have given are live, so that you can try with it. Please go through these and kindly help me to resove this issue.

     

    Thursday, June 30, 2011 12:07 PM
  • User-176674611 posted

    Hi,

    The issue is caused by you didn't add the prefix "Category" in your outbound rule. Also I suggest you change your pattern a bit, for your pattern will only pass evaluation for absolute urls. The rule will look like:


    <rule name="OutboundRewriteUserFriendlyURL1" preCondition="ResponseIsHtml1" >
      <match filterByTags="A, Form, Img" pattern="^(.*)category\.aspx\?CCode=([^=&amp;]+)$" />
      <action type="Rewrite" value="{R:1}/Category/{R:2}/" />
    </rule>

    Thanks.

     

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Thursday, June 30, 2011 9:55 PM