views:

63

answers:

4

Hello.

I want to build a web application where users can register and have a profile. People can visit the profiles adding the user name in the url like this.

http://mysite.com/john

How can I create this url for each registered user

I taught using mod_rewrite to rewrite the url but are there any other aproaches?

by the way I want to use Struts 2 and tomcat as server

A: 

Here is a silly way, create a directory for each user on the server then put an index.htm or default.htm in it. LOL. This was the way my university setup their web server so that each student could have his own mini website address like http://www.myuni.com/~myuser

Andrew Keith
hahaha thx any other aproach?
Enrique
+1  A: 

if you wanted to do something like http://bob.mysite.com you could achieve this using wildcard DNS, here is an example of how it can be done on a cPanel server:

http://www.actiononline.biz/web/enabling-wildcard-dns-on-cpanel-servers/

Essentially this allows you to create unlimited amounts of subdomains by parking domains on top of the core domain.

seengee
A: 

This question/answer combo may help you on the right path: http://stackoverflow.com/questions/173846/struts2-how-to-do-dynamic-url-redirects

nstehr
A: 

Thank you very much. I found this filter http://tuckey.org/urlrewrite/ so I'm going to use it. It works for web applications that use Servlets like Struts, Spring etc.

Enrique