URL Rewriting Help

View: New views
2 Messages — Rating Filter:   Alert me  

URL Rewriting Help

by dhoma.mahipal@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi Avlesh,

Please help me out with the URL rewriting for the below scenario.

Rule 1:

<rule>
    <from>/category/([^/]+)/([^/]+)</from>
    <to>/search-category?catname=$1&categoryID=$2</to>
</rule>

<outbound-rule>
    <from>/search-category/?catname=(.*)amp;categoryID=(.*)</from>
    <to>/category/$1/$2</to>
</outbound-rule>

The URL will be like www.example.com/category/computers/comp1

Now we need to change the URL to www.example.com/computers/comp1


Rule 2

<rule>
    <from>/product/([^/]+)/([^/]+)$</from>
    <to>/product-desc?productName=$1&productID=$2</to>
</rule>

<outbound-rule>
    <from>/product-desc/?productName=(.*)amp;productID=(.*)</from>
    <to>/product/$1/$2</to>
</outbound-rule>


The URL will be like www.example.com/product/java/98745687

Now we need to change the URL to www.example.com/java/98745687

For Rule 1 and Rule 2 we should know which request has to be called
because both has the same URL format. To resolve this we were using
product and category as the sub context which is becoming a problem
for the URL depth.


Rule 3

<outbound-rule>
    <from>/search-author/?authorName=(.*)</from>
    <to>/search-author/$1</to>
</outbound-rule>

<rule>
    <from>/author/([^/]+)$</from>
    <to>/author?authorName=$1</to>
</rule>


The URL will be like www.example.com/author/peterson.

Now we need to change the URL to www.example.com/peterson


Rule 4

<rule>
    <from>/search/([^/]+)$</from>
    <to>/general-search?searchkey=$1</to>
</rule>

<outbound-rule>
    <from>/general-search/?searchkey=(.*)</from>
    <to>/search/$1</to>
</outbound-rule>

The URL will be like www.example.com/search/peterson.

Now we need to change the URL to www.example.com/peterson

For Rule 3 and Rule 4 we should know which request has to be called
because both has the same URL format. To resolve this we were using
author and search as the sub context.


The environment we are using are

1. JSP, Servlets, Spring and Hibernate
2. Server - Tomcat
3. URL Rewriting - Tuckey  urlrewrite3.2


Please help us to resolve the problem.

Thanks in advance.

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


Re: URL Rewriting Help

by Avlesh Singh :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Mahi,
Unfortunately, there is no solution for the problem at UrlRewrite layer.
A similar query was answered a few days back here - http://groups.google.com/group/urlrewrite/browse_frm/thread/6b7a476ece9003e3/80c3ac69010b852e

If I had this problem at hand, I would write an intercepting filter, which can go to the database and find out the corresponding object's type and then forward the request to the right controller.

Cheers
Avlesh

On Thu, Sep 24, 2009 at 3:50 PM, Mahi <dhoma.mahipal@...> wrote:

Hi Avlesh,

Please help me out with the URL rewriting for the below scenario.

Rule 1:

<rule>
   <from>/category/([^/]+)/([^/]+)</from>
   <to>/search-category?catname=$1&amp;categoryID=$2</to>
</rule>

<outbound-rule>
   <from>/search-category/?catname=(.*)amp;categoryID=(.*)</from>
   <to>/category/$1/$2</to>
</outbound-rule>

The URL will be like www.example.com/category/computers/comp1

Now we need to change the URL to www.example.com/computers/comp1


Rule 2

<rule>
   <from>/product/([^/]+)/([^/]+)$</from>
   <to>/product-desc?productName=$1&amp;productID=$2</to>
</rule>

<outbound-rule>
   <from>/product-desc/?productName=(.*)amp;productID=(.*)</from>
   <to>/product/$1/$2</to>
</outbound-rule>


The URL will be like www.example.com/product/java/98745687

Now we need to change the URL to www.example.com/java/98745687

For Rule 1 and Rule 2 we should know which request has to be called
because both has the same URL format. To resolve this we were using
product and category as the sub context which is becoming a problem
for the URL depth.


Rule 3

<outbound-rule>
   <from>/search-author/?authorName=(.*)</from>
   <to>/search-author/$1</to>
</outbound-rule>

<rule>
   <from>/author/([^/]+)$</from>
   <to>/author?authorName=$1</to>
</rule>


The URL will be like www.example.com/author/peterson.

Now we need to change the URL to www.example.com/peterson


Rule 4

<rule>
   <from>/search/([^/]+)$</from>
   <to>/general-search?searchkey=$1</to>
</rule>

<outbound-rule>
   <from>/general-search/?searchkey=(.*)</from>
   <to>/search/$1</to>
</outbound-rule>

The URL will be like www.example.com/search/peterson.

Now we need to change the URL to www.example.com/peterson

For Rule 3 and Rule 4 we should know which request has to be called
because both has the same URL format. To resolve this we were using
author and search as the sub context.


The environment we are using are

1. JSP, Servlets, Spring and Hibernate
2. Server - Tomcat
3. URL Rewriting - Tuckey  urlrewrite3.2


Please help us to resolve the problem.

Thanks in advance.

Regards,
Mahipal



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