Trailing Slash redirect and canonical URLs #129
Replies: 1 comment 1 reply
-
Well, I'm still thinking that trailing slashes should be the way to go by default. Simply because is how it works the SWS right now. However, I don't see why we can not make the that feature optional.
You are right, the code lines above are where the redirection happens. Also, we could turn this thread into an issue and reference it in the next PR. |
Beta Was this translation helpful? Give feedback.
-
Hi!
First off thanks a lot for working on this awesome project!
I have an issue where I am not sure whether this could be a bigger SEO problem.
In #74 you implemented a feature that results in webpages (
index.html
) always being redirected to a trailing slash.E. g. calling
.../blog/post1
will always get a 308 and redirect to.../blog/post1/
.I think this could cause problems in cases where websites use canonical urls without a trailing slash. Crawlers want to crawl the canonical document, get redirected, and not be on the canonical document. I am pretty sure that this causes errors in my google search console (error message says: redirect error). But strangely these errors do appear consistently, I have many pages indexed under the canonical URL but sometimes when I manually tell Google to index a page this error does occur.
You could argue that I could change my canonical tags to trailing slashes on all pages. But on an established site where much is already indexed, I guess this could be a huge risk as search engines could re-index (und unrank) everything as they want the canonical document (I am absolutely not sure about this).
It is also not uncommon to use canonical URLs without trailing slashes. Google says they don't care which to use.
What do you think about a flag that disables the redirect logic: https://github.com/joseluisq/static-web-server/blob/6840d0fc21a4f5d742c6435987b40ecdf00f5d01/src/static_files.rs#L63-L80 . I experimented with a fork where I compiled your source code without the redirect and everything seems to work fine for me.
If you agree to a flag like this I would try to open a PR for it (I have little Rust experience).
Beta Was this translation helpful? Give feedback.
All reactions