Use or not to use a slash at the end of a URL?

3

Whenever I'm going to create a new website and think about .htaccess , I hit that doubt: force or not force the use of the slash at the end of the URL.

For example: link would be 301-redirected to link .

By doing this redirection, the loading time may take a little longer, little I know, but each bit counts in a large site.

By not adding the final slash, however, it can cause duplicate content in Google listings, and undermine the site's SEO.

So, definitely whether or not to use the forward slash at the end of a URL? And what are the main reasons?

    
asked by anonymous 29.01.2014 / 20:39

3 answers

4

Using rel="canonical" , is at your discretion. Example:

I insert it in the head of the page, with the original page name in "href":

<link rel="canonical" href="http://www.exemplo.com.br" />

Then google will read, and if the content is equal, it will play the entire ranking in the url that is in the href, so in these pages below I have directed it to http://www.exemplo.com.br :

  • http://exemplo.com.br
  • http://www.exemplo.com.br
  • http://www.exemplo.com.br/
  • http://www.exemplo.com.br/index.html
29.01.2014 / 21:32
4

The idea that doing a 301 redirect cause pagerank loss is a Myth , and you have nothing to worry about. Any answer in addition will probably be a matter of personal opinion. As long as your urls serve the same content, either have or not the bar at the end .

    
29.01.2014 / 20:45
2

For the main URL of the domain, I find it unnecessary to place the slash at the end, since some browsers like Chrome already remove the slash automatically from the address bar: See the behavior when typing in the Chrome address bar:

  

http://localhost/

is automatically simplified to

  

localhost

However, there is a caveat regarding the system running on the server side, which may interpret the requested URL differently. For example a system may be using the URL and separating the bars for some internal use.

Example in PHP:

<?php print_r(explode('/', $_SERVER['PATH_INFO'])) ?>
  

http://localhost/index.php/modulo/

Print a first 'module' item and a second empty item

  

http://localhost/index.php/modulo

You will only print a first 'module' item.

That is, for SEO account do not think necessary, the systemic level depends on each case.

    
29.01.2014 / 21:06