Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

What's the current best practice around path parameters in URLs?

For instance

/artist/name

A long time ago I might have made artist.html and then passed in a query parameter /artist.html?name=name but it seems path parameters are the standard (and nicer to look at).

So assume I'm using apache, nginx, etc. Are these just rewritting /artist/name to '/artist.html?name=name` and then the Javascript is reading the query parameters? How is this done in the static html / ajax world we live in?

Thanks

share|improve this question

closed as unclear what you're asking by MainMa, durron597, MichaelT, GlenH7, Snowman Aug 24 at 23:33

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Your question is unclear. Why are you talking about JavaScript? What do you mean by “static HTML/AJAX world we live in”? You are probably looking for the term “URL rewriting”. –  MainMa Aug 22 at 20:03
    
By static html page -- I mean static html pages that are not manipulated by the server via a template / jsp like pages. –  Shaun Aug 23 at 17:52

1 Answer 1

up vote 0 down vote accepted

While that's probably how it used to be before (and I do remember writing stuff like that myself), modern websites tend to use web frameworks such as Flask or Django or Ruby on Rails instead of static pages and rewrites.

These frameworks include URL routing, where a certain pattern in the path, for example /artist/<name>, can be mapped to a function getArtist(name).

The query string may then be read by either the backend program or some JavaScript in the page.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.