bestmomo's avatar

Pagination trailing slash

Hi guys !

L5 pagination generates url with "/?" (it was not in L4), that is not managed by all servers (for example my WAMP server doesn't like it). In my projects I always remove this trailing slash and all is fine. But I've read that "/?" is a correct syntax. So I read the ugly RFC 3986 and I didn't find any reference to this trailing slash.

So I wonder about that. Any thought about it ?

0 likes
14 replies
sitesense's avatar

Here's some info from Google (quite old now but whatever).

http://googlewebmastercentral.blogspot.co.uk/2010/04/to-slash-or-not-to-slash.html

TL;DR: For SEO purposes it doesn't seem to matter much.

However, this seems a reasonable argument for the use of trailing slashes:

https://cdivilly.wordpress.com/2014/03/11/why-trailing-slashes-on-uris-are-important/

Regarding the RFC, I think this is the relevant part:

If the base URI has a defined authority component and an empty path, then return a string consisting of "/" concatenated with the reference's path; otherwise,

return a string consisting of the reference's path component appended to all but the last segment of the base URI's path (i.e., excluding any characters after the right-most "/" in the base URI path, or excluding the entire base URI path if it does not contain any "/" characters).

sitesense's avatar

@bestmomo are you referring to a trailing ? with no parameters?

I guess that isn't necessary at all, although it may have benefits...

Say somebody visited /my_paginated_list/ then went elsewhere but then returned to /my_paginated_list/ - the browser may have cached that page and any recent changes might not be seen.

If however they visited /my_paginated_list/?, the page would be refreshed and new content would be loaded. I.e. the ? forces a refresh.

bashy's avatar

I work along side an SEO company and they prefer trailing slash. As long as you keep it the same across the site it's fine.

You can also use canonical URL to give Google and other search engines the link you want findable: https://support.google.com/webmasters/answer/139066?hl=en

For the above, I would use uri?query=foo

sitesense's avatar

@bestmomo from what I can make out from the second link that I sent and the RFC is this:

If you were to convert an absolute URI to a relative URI, you may have a problem because during the conversion the base path would be found by looking for the right-most "/".

Therefore, if a trailing slash is not used, http://mysite.com/blog/posts?content=cats when converted to a relative URI could become http://mysite.com/blog/?content=cats.

A bit confusing but I think I get it.

bashy's avatar

Actually, if you force trailing slash - you will need to use /uri/?query=foo since without the slash before the question mark will redirect to trailing causing a 301.

sitesense's avatar

To extend on what @bashy was saying, if you have a URL that ends like /mypage and a URL that ends like /mypage/, they are considered as different content, so for SEO purposes it's recommended to use one or the other. Although Google states that it's not that important.

bestmomo's avatar

Thanks for answers, but for now i'm still a bit puzzled ^^

But am I the only one to experience issues with this "/?" ?

bobbybouwmann's avatar

I'm using homestead and I never had issues with it, but I didn't noticed until today that some om my problems have the trailing slash in the url as well. Projects on forge also didn't have any trouble with it..

bashy's avatar

Depends how web server setup handles them.

bestmomo's avatar

@Mario Nava

This issue depends on your server. One simple way is to delete trailing slash when you generate links :

$links = str_replace('/?', '?', $posts->render());
1 like

Please or to participate in this conversation.