views:

58

answers:

2

In an MVC framework, I have a model with an "identifier" field. This field can be whatever is used by the user as their unique identifier. I then use this identifier field in URLs to access the relevant resources.

/people/<identifier>/

In one such case, the user is using identifiers of the format 00/000. The quick among you will have spotted the problem straight away - how do we know which part is the identifier, and which part the action?

The obvious solution is to use URL escaping (%2F being the relevant code). However, this confuses my apache load balancing proxy as well as the application server on our demo box (running passenger). Although annoyingly this works fine on the local development servers. URLs including %2F seem to cause 404 errors from the server (not the application!).

What i'm looking for is a general approach to solving this problem, while keeping a tidy URL.

The stack which caused this problem is: Ruby 1.8.7, Merb 1.0.12, Apache load balancing to a thin cluster on production, Passenger on the demo server, and working with unproxied thin on development.

+4  A: 

The cleanest way would be to prevent the user from entering in a forward slash character in the first place. If it is necessary to support this format, then there is no way around having to use URL escaping.

Scott M.
I'm resigned to having to use some form of escaping to allow this format - however using standard URL escaping confuses the server. I'm after suggestions for alternate methods of escaping that look nice in the URL bar
Glenjamin
+1  A: 

You could always use a home-grown encoding that replaces / with some other character that is never used in your identify field and then converts it back when reading it from the URL.

For example:

http://yoursite/people/00/000

becomes

http://yoursite/people/00-000

Chris
Unfortunately each user of the system uses a different format for their numbering - and I need to be able to support them as best as I can. I'm currently replacing "/" with "slash" (the word) which seems a bit silly but ultimately works.
Glenjamin