Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trailing slash before a query string. Bad practice?

I have a URL like www.example.com/store/, which leads to a store page

When a user clicks on a discount link, it adds the parameter ?discount=foo, so my link looks like this: www.example.com/store/?discount=foo.

Everything is functional. But is it bad practice to have the forward slash before the query string in this situation?

like image 727
Max Martel Avatar asked Apr 24 '15 18:04

Max Martel


People also ask

Should there be a slash before query string?

As a matter of modern spec, yes, it is permissible to skip the slash, contrary to what the accepted answer here claims.

Is trailing slash good or bad?

Trailing slashes can be bad for the user experience Whether a URL has a trailing slash or not, it's viewed as a unique and individual web page. If the same URL exists both with a trailing slash and without one, it means the content on the page could technically be different.

Does Google care about trailing slash?

Google does not care whether or not you use a trailing slash in your URLs. The thing that does matter is how you use them – Google counts each one as a different URL.

Should not specify a trailing slash?

The short answer is that the trailing slash does not matter for your root domain or subdomain. Google sees the two as equivalent. But trailing slashes do matter for everything else because Google sees the two versions (one with a trailing slash and one without) as being different URLs.


1 Answers

It’s valid:

  1. The path component may end with a slash (/).
  2. The query component starts with the first question mark (?) in the URI.
like image 185
unor Avatar answered Sep 19 '22 09:09

unor