I'm working with a Laravel app and am development a "referral" feature. A user clicks "refer friend" and a URL pops up that can be shared on Facebook etc, when another user clicks on the link they are taken to the site, a session parameter is set, and later if the user signs up, the original user gets credit.

There are two ways to accomplish this. a query string www.example.com?invite=123 or routing parameter www.example.com/invite/123

As I was reading this answer https://softwareengineering.stackexchange.com/questions/270898/designing-a-rest-api-by-uri-vs-query-string/285724#285724 I seemed to get the idea that query strings are useful for non-hierarchical data. This is how sites such as Copy.com work with their rerrals.

But looking at other examples on the internet, for example DropBox, Lyft, Hulu, Uber and others use route parameters (more seem to use route parameters than query parameters).

A query string is more cumbersome or confusing verbally tell someone or to write down on paper (and less visually appealing), but it also makes site previews easier when sharing on Facebook (no need to dynamically generate og:image tags etc each time the URL and code are parsed)

Is one really more correct than another? Is there a standard for this or is it all preference?

EDIT: Do either of these options affect SEO? For example would www.example.com/invite/123 rate differently than www.example.com?invite=123 when a page is crawled containing either of these links?

2 Answers 2


This form


is preferable when your URL refers to something concrete and specific, like a business entity, transaction or document. The word "invite" typically refers to a controller method.

This form


is preferable when you want to modify the operation or resource at the designated URL using parameters. For example, the URL for a search page might look like this:


Many frameworks don't make a real distinction at the back-end code level between route (URL) parameters and query-string parameters, making this mostly a matter of style. URL parameters are best when you're identifying a specific resource on the back-end, eg. someone responding to a specific invitation code. For your purpose of a referral code, a query-string parameter added to the normal URL for the sign-up page or other destination would be a better fit. It avoids the problem of determining which real URL the user should be redirected to after recording the referral and the problem of adding this parameter to every single route involved and allowing it to be optional (which in many frameworks involves either 2 distinct routes or dark magic in the routing). The query-string parameter, by contrast, can be handled by a common check applied to every page that stores the referrer code if it's present and none is already recorded for the user.

As far as SEO, the query-string form will probably perform better because the Web spider will usually disregard the query string and all links will count as going to the same page, whereas with the routing-parameter form each code will count as a different page even when in reality they all end up at the same place. Search engines typically count the path portion when deciding what the target URL is, and treat the query string as parameters being passed to that page rather than affecting the target page of the link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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