2

I want to have SEO friendly urls in my application, which will be built in java/j2ee using Struts (1/2).

I have some classifications as follows

county/countryname
county/state/statename
county/state/locality/localitname

I guess above URLs will be seo friendly?

How can I have such URLs with Struts instead of something like /county='xyz' ?

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
akshayxyz
  • 3,423
  • 3
  • 16
  • 11
  • Please check the wonderful Play! Framework at http://www.playframework.org/. I think you will like it. – qeek Apr 23 '11 at 05:59
  • i had tried play framework. but i dont think its stable like ror or django ,so i dont think it can be used for large webapp – akshayxyz Apr 23 '11 at 06:03
  • @qeek : Can you please suggest me, play looks good, but am not sure if it can be used for big webapp.Is it stable? please comment – akshayxyz Apr 23 '11 at 06:28
  • See here: http://www.playframework.org/community/testimonials I guess it's as stable as Java in the end :) – qeek Apr 25 '11 at 18:07

3 Answers3

3

use urlrewrite library, it will integrate nicely with most of the java web frameworks.

example from here:

In the following example requests for /world/usa/nyc will be transparently forwarded to /world.jsp?country=usa&city=nyc

<rule enabled="true">
   <from>^/world/([a-z]+)/([a-z]+)$</from>
   <to>/world.jsp?country=$1&amp;city=$2</to>
</rule>
kdabir
  • 9,623
  • 3
  • 43
  • 45
2

You can use Apache mod_rewrite, it will convert your URLs like http://myapp.com/u/nishant/page/account/tab/3 to http://myapp.com?u=nishant&page=account&tab=3. So, your app don't need to worry about how URL structure.

Alternatively, you may use URLRewriteFilter, which is nothing but a cleverly written filter that need to the first filter of your application and all the requests should pass through this. It follows the same pattern rules as Apache mod_rewrite.

Nishant
  • 54,584
  • 13
  • 112
  • 127
1

I don't think this can be done with Struts. You'll need Filters in order to achieve this.

Vicente Plata
  • 3,370
  • 1
  • 19
  • 26