how do i differentiate between two or more url Rules

2 views
Skip to first unread message

pramod

unread,
Sep 4, 2009, 9:07:12 AM9/4/09
to UrlRewrite
here is my que...
if my 1st rule is----
1)<rule enabled="true">
<from>^/newlisting/([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)$</from>
<to>/newlisting.jsp?country=$1&amp;state=$2&amp;city=$3&amp;cat=
$4</to>
</rule>

and if 2nd Rule is----
2)<rule enabled="true">
<from>^/newlisting/([a-z]+)/([a-z]+)/([a-z]+)/([a-z]+)$</from>
<to>/newlisting.jsp?country=$1&amp;state=$2&amp;city=
$3&amp;company=$4</to>
</rule>

in above rules last parameter are different for them, for 1st it is
"cat=$4" and for 2nd it is "company=$4".
i use these 2 Rules because i hv navigation search under my
application, like
1)by category
2)by company
3)by type.....etc

if i click on company then it takes company as category...and my query
goes wrong.
plzzzz help me to overcome this problem.

thanx in advance.
regards......

Avlesh Singh

unread,
Sep 4, 2009, 8:32:41 PM9/4/09
to urlre...@googlegroups.com
Well, no amount of url rewriting can help you here. The two rule you have used are exactly similar and everything will match the first rule. Couple of things you can do here -
  1. If your category/company/type etc is a definitive list, then you can put them in the rule itself like this - "<from>^/newlisting/([a-z]+)/([a-z]+)/([a-z]+)/(category1|category2|category3)$</from>". And you can have similar rule for all of the different types.
  2. Just have one different delimiter for each type. So, basically, I am suggesting you to have URL's like these - "/newlisting/country/state/city/category/my-category-name", "/newlisting/country/state/city/company/my-company-name" etc. You can simply rewrite using 3 rules based on these boldened delimiters.
  3. This is off the filter - you can always have just one rule, and everything matches that one rule. Once you get the data in your servlet, you can figure out what it is.
Cheers
Avlesh

pramod

unread,
Sep 7, 2009, 1:34:19 PM9/7/09
to UrlRewrite
thank u for giving a reply........
but can u please give me the example for 2nd option which u specified
abt delimiters
>>>" 2. Just have one different delimiter for each type. So, basically, I am
suggesting you to have URL's like these - "/newlisting/country/
state/city/
*category*/my-category-name",
"/newlisting/country/state/city/*company*/my-company-name"
etc. You can simply rewrite using 3 rules based on these boldened
delimiters. ">>>>>>>>>>>

actually not getting how do i use delimiters here.....?
thank you!

Avlesh Singh

unread,
Sep 7, 2009, 2:05:23 PM9/7/09
to urlre...@googlegroups.com
but can u please give me the example for 2nd option which u specified abt delimiters
I was talking about having different URL structures for different types. e.g in your case, you can design the URL's like these
  • /newlisting/country/state/city/company/my-company-name
  • /newlisting/country/state/city/category/my-company-name
  • /newlisting/country/state/city/some-other-type/my-company-name
If it is okay to have these url's in your application, then you can simply write three different rewrite rules, sending each one of the above to a different "to" url without ambiguity.

Cheers
Avlesh

pramod

unread,
Sep 7, 2009, 3:28:00 PM9/7/09
to UrlRewrite
it helps me alvesh, thank you!

Thanks again for your help...

qizhi chen

unread,
Dec 27, 2009, 1:23:57 AM12/27/09
to urlre...@googlegroups.com
well done
2009/9/8 pramod <pramod.u...@gmail.com>

it helps me alvesh, thank you!

Thanks again for your help...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "UrlRewrite" group.
To post to this group, send email to urlre...@googlegroups.com
To unsubscribe from this group, send email to urlrewrite+...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/urlrewrite?hl=en
-~----------~----~----~----~------~----~------~--~---




--
http://www.jackshow.net
Reply all
Reply to author
Forward
0 new messages