Best unofficial Apache Server developers community
Username
Forgot password?
Sign in with Twitter account
Sign in with Facebook account

A Way to Group URLs

0

36 views

I have a list of URLs, each associated with a set of numbers. For example:

http://example.com/ - 0
http://example.com/login/ - 1
http://example.com/login/verify/ - 2
http://example.com/user123/home/ - 3
http://example.com/user254/home/ - 3
http://example.com/user123/edit/ - 4

I want some method to 'compress' this, maybe using regexp -- the catch is that for all URLs not in the list I can assume they map to whatever number I want.

So an output like this -- any URL is checked against each expression in this order, and given a number according to the first match.

http://example.com/login/verify* - 2
http://example.com/login/* - 1
http://example.com/*/home/ - 3
http://example.com/*/edit - 4
http://example.com/* - 0

Note: There are multiple possible outputs like this that are acceptable. Also, I considered something like a tree, where each node contains an expression like one of the above, and the leaves at the end are the actual URLs to check against.

Another Note, I said mapped to numbers for simplicity's sake. Actually, they are mapped to a set of numbers, where the set has to match. Just in-case that helps someone come up with a solution (though I doubt it).

asked March 23, 2011 11:00 am CDT
posted via StackOverflow

2 Answers

0
 

well, i understand what you whant but let me adertise you about the SEO "Search engine optimization", your required solution is completely out or purposes (on SEO way).

But assuming that SEO is not important, try to create a session variable that stores your urls, by this way you can create map a url to a number (maybe the array position or a dictionary).

After that what you must do is to create a httpmodule that uses regexp to determine what your urls mapping to your session dictionary.

This httpmodule must be capable to rewrite the full ulr (replacing the number for your session stored value) and execute it.s

answered March 23, 2011 11:23 am CDT
0
 

It looks like you need a different regex for each URL match, they would probably look something like this.

http://example\.com/login/verify
http://example\.com/login
http://example\.com/[^/]+/home
http://example\.com/[^/]+/edit
http://example\.com

Try to match the URL to each of these in order, then when it matches look up the number (or set) that corresponds to that match.

answered March 23, 2011 11:23 am CDT

Your answer

Join with account you already have


Sign in with Twitter account
Sign in with Facebook account
Sign in with Google Friend Connect

Preview
Similar questions
'?' versus '#!' in URLs
February 8, 2011
Personalized URLs
February 11, 2011
Add omitted ? to URLs
February 18, 2011
Notify change of urls
January 7, 2011
Htaccess rewrite urls
March 10, 2011