Slash URL end

Last Updated:

It's not as common a topic as some other topics, but a very important one. And the first question is whether using or without a slash at the end of the URL would be the better choice for our SEO. But Google does not comment on it but tells us what it means for Google with a slash at the end of the URL or without a slash.

Without a slash (slash) does that mean for Google, it became one File called from the server. However, if a slash on the end, that means for Google, the one Folder was called. If you want to know more about it, then you can read more on the Google Webmasters blog.



There are several ways to get the different things under control and you should.



With a slash or without a slash at the end

If we use speaking URLs it would make sense to put a slash at the end. However, we use an extension like .html at the end or another kind, which is relevant for us (Google recommends html endings). In tnado both and more is possible that's why I removed the slash at html endings and added no slash to any extension.

Add a slash and remove in HTML extension via htaccess


// HTACCESS CODE
     0  # Add Trailing Slash to the URL to safe duplicate content  1  RewriteCond %{REQUEST_URI} ^/[^\.]+[^/]$  2  RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1/ [L,R=301]  3    4  RewriteRule (.+)\.html/$ /$1.html [L,R=301] 

    We add a Slash at the end of the URL with each call and with the other command we remove the Slash with HTML extensions. So we can add several extensions and remove the slash at the end. Then we made sure that the other extension we use did not fall victim to a slash.



    Avoid mistakes when linking

    It can happen that we have relative paths on one side

    <a href="/path/file.html">Files</a>

    used on our links. If exactly this page without one slash is called at the end of the URL


    https://www.tnado.com/de/blog/url-mit-oder-ohne-schraegstrich

    or achievable, then the relative paths look quite different and that way

    https://www.tnado.com/de/blog/url-mit-oder-ohne-schraegstrich/path/file.html

    you certainly did not want to achieve that, because this URL does not exist and should normally look like this

    https://www.tnado.com/path/file.html

    as it was supposed to be we get this when our URL is called with a slash at the end.


    https://www.tnado.com/de/blog/url-mit-oder-ohne-schraegstrich/
    So that this mistake does not happen to us and Google and not with 404 errors to pour

    Let's use the technique shown above to prevent URLs from being misrepresented.