URL rewrite dynamic urls

Discussion in 'Search Engine Optimization' started by kurtsfar, Nov 28, 2005.

  1. #1
    Hi, I have created a dynamic tree navigation in jsp.
    Each node in this tree has a node-number and a true or false varible.

    When a user press the node the url could look like like this:

    http://mec.mine.nu/?node=29623436&shouldOpen=true

    I use server-side-includes to include the dynamic tree on each page.
    This is how the tree looks like when there is no styling:

    http://mec.mine.nu/casina/nav.jsp

    This is how the tree looks like when I have included it in my index.jsp page:

    http://mec.mine.nu/

    I have heard there could be a problem for some search engines to follow these kind of dynamic links. I there for was thinking about making the node-numbers static and try to use pathinfo instead of the querystring.

    What I want is the URL to look like this:
    http://mec.mine.nu/29623436/true/

    instead of:

    http://mec.mine.nu/?node=29623436&shouldOpen=true
    However I not managed to do this yet, and I was hoping to get some help.

    Thank you
     
    kurtsfar, Nov 28, 2005 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/true/$ index.jsp?node=$1&shouldOpen=true [L]

    if it's always true. Even better....

    RewriteRule ^([^.]+)/$ index.jsp?node=$1&shouldOpen=true [L]

    Just make sure it doesn't mess up any other part of the site. Giving it a unique extention in the final URL would fix that.
     
    Nintendo, Nov 28, 2005 IP
  3. kurtsfar

    kurtsfar Guest

    Messages:
    37
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply!
    I use the servlet engine/container Apcache Tomcat 5.5, not the usual Apache. I know I might be able to use the usual Apache with a connector and mod_rewrite.
    (probably a bit more secure)
    However, the latest release of Tomcat is concidered to very secure even as standalone, and since I have all my pages in jsp it feels better to use Tomcat by itself.

    I also know there is a non-standard release of Tomcat that use a filter equal to the usual Apache's mod_rewrite, but the code is not open source, and I really want to be sure of what I am doing.

    I have been expermenting with request.getPathInfo(), and it seems to work, but only when I use a servlet.
    When I try it on a servlet an example of the url would be:

    http://mec.mine.nu/test/1/true

    test is the servlet with an url-pattern like this in web.xml:/test/*
    1 is the node, and true stands for that the node should open

    When I try the same in jsp an example of the url would be:

    http://mec.mine.nu/test.jsp/1/true

    This, or any other url-pattern I have tried doesn't work: /test/*

    The source is not found and I get a 404 error.

    Thanks again for trying...but I hope u can help me some more:)
     
    kurtsfar, Dec 2, 2005 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    I have no idea what to do with Tomcat.
     
    Nintendo, Dec 2, 2005 IP