url rewriting problem in tomcat with apache

Discuss practical ways rearrange URLs using mod_rewrite.

url rewriting problem in tomcat with apache

Postby vikasparmar » Sat Jun 07, 2008 2:28 pm

I want to rewrite the dynamic url which is generated using jsp and I am using tomcat and Apache which are connected using mod_jk.

Here is the scenario:

Dynamic url:

Code: Select all
http://localhost/GeekMantra/subsection?section=JSP


Final static url I want is:

Code: Select all
http://localhost/GeekMantra/subsection/section/JSP


All the things are going fine but I can't able to implement the url rewrite rule, means I can't able to figure out where should I place my rewrite rule so that apache can map it in static url.

I had tried the following in httpd.conf file but with no success:

Code: Select all
<VirtualHost localhost:8080>
   #    ServerAdmin webmaster@dummy-host.example.com
   #    DocumentRoot /www/docs/dummy-host.example.com
   ServerName localhost
     #    ErrorLog logs/dummy-host.example.com-error_log
   #    CustomLog logs/dummy-host.example.com-access_log common

Options +FollowSymLinks
RewriteEngine on
RewriteRule http://localhost/subsection/(.*)/(.*)/$ /GeekMantra/subsection?$1=$2
</VirtualHost>   



Please help as I am desperately want it to be done.
vikasparmar
 
Posts: 1
Joined: Sat Jun 07, 2008 12:33 am

Postby richardk » Mon Jun 09, 2008 12:56 pm

Try
Code: Select all
<VirtualHost localhost:8080>
  ServerName localhost
  Options +FollowSymLinks

  RewriteEngine On

  RewriteRule ^/GeekMantra/subsection/([^/]+)/([^/]+)/?$ /GeekMantra/subsection?$1=$2 [QSA,PT,L]
</VirtualHost>

Mod_rewrite will not change the links in your pages.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 21 guests

cron