Clean URL's Redirect from non-trailing slash to trailing slash

I do like the way that you can simply opt Blocs to output Clean URL’s with no .html or .php.

The option creates a trailing slash. http://mysite.com/filename/

And even better that Blocs creates a re-direct from… http://mysite.com/filename to http://mysite.com/filename/ to counter Google thinking there’s two URL’s

So I assumed a .htaccess file was generated but it’s not!

Question… So how is the re-direct being performed?

Nope. It’s not file name, it’s folder name. And by specification a folder ends with a trailing slash.

The following index.html is just omitted and served by the server as default file.

1 Like

I knew its a folder with an index file. That was not the question I asked.

What is doing the re-direct from…

http://mysite.com/foldername (no slash)

to

http://mysite.com/foldername/ (with slash)

filename changed to foldername to be clearer.

Try it in a browser. (Before you say .htaccess file there isn’t one created by Blocs)

Blocs isn’t creating .htaccess files.

The server itself.

2 Likes

Would you even call it a redirect? It’s just a / because it’s a folder. They are not two different URLs IMO.

Sorry maybe I’m not being clear enough. I’m not referring to folders or files. Nor the way a folder name URL can hide the index.html filename

I referring to the automatic re-direct Blocs does between the two 2 URL’s :point_down:

http://mysite.com/foldername (this - no slash)

and

http://mysite.com/foldername/ (to this with slash)

Study these carefully.

Google treats these as two different URL’s so normally you’d add a .htaccess files to redirect from one to the other.

Somehow Blocs is doing this function. I was asking how?

If you’re using Clean URL’s try knocking off the trailing slash on the folder name and load the page - it adds the slash.

Interesting. I just had a read up on some google docs. Good to know.

I would suggest its the rel=“canonical” tag stops that potential double up.

Blocs isn’t doing this. It’s the server.

I have set up this blank domain with no Blocs project or own htacces file involved: http://test.blocsaddons.com/test

Yes sir. The 301 redirect is done by the server.

2 Likes

I always add the trailing slash in project settings and found Scrutiny scans the site better like that without canonical issues. In addition, I have also found that social cards only show up properly when the trailing slash is added to the url.

1 Like

After a few tests it’s yes by the server when there’s an index.[*] file present

http://davidowen.me.uk/test

I’ve never noticed that subtle server behaviour on a subfolder before. But then I’ve never built a site with every page as an index page inside a folder (with the folder name as the filename you would have used otherwise) to take advantage of it.

I assume there’s no known SEO downside for this?

…which raises the question of wanting multiple Blocs pages in a subsection folder?

http://mysite.com/products/bluewidgets/
http://mysite.com/products/greenwidgets/
http://mysite.com/products/redwidgets/

Can Blocs do this and still keep clean URL’s?

That’s Good!