-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trailing slash issues #3127
Comments
Can you try Grav 1.7, it should work there. |
It does not work. |
I've seen the 301 fix which looks good. However the canonical of the root page is still wrong, I guess (unless there was a recent fix I missed). |
You mean this: |
Yes! It should be |
Oh, now I think I remember why I didn't do 301 redirects. On the home page, it caused a loop between slash and no slash and never ended up requesting anything from the server. |
Well, that needs to be fixed than. I dont think the redirect code itself makes any difference here, it is just a cosmetic thing for search engines, isnt it? |
I think it has been fixed, but the main issue was that when you accessed the page, it redirected without ever contacting the server. So the only way to fix that was to clear the cache in the browser. |
Alright, but what about the canonical URL? That should be independent. I've suggested a possible fix in my first post, but there might be better solutions. |
Well, there was actually a second issue that is not related to SEO. Create a Grav site and in there create Now try to access:
The links end up pointing to a different instance, the first one stays in the Grav site, and the second loads the PHP info. This means that the root page should always have the trailing slash or the home page may not work properly. |
Wow, that is a simple fix. Are you sure this does not break? For example if you run Grav in a subdir |
I have tested it with language prefixes. Though it will not make any difference as the only slash that will remain is coming from |
So basically it redirects I made this change for two reasons:
|
Sounds reasonable. I will give it a try later this day. Thanks a lot for taking the time! |
Seems to be fixed for me, I will close this. Super nice! |
There are multiple issues with trailing slashes in Grav.
The current situation:
https://mywebsite.de/contact
is the canonial urlhttps://mywebsite.de/contact/
redirects tohttps://mywebsite.de/contact
with 302 status codehttps://mywebsite.de/
, nothttps://mywebsite.de
due to the http protocol. Browsers do not display them though!Those are the current issues:
https://mywebsite.de/
is the website root with a canonial ofhttps://mywebsite.de
https://mywebsite.de
instead ofhttps://mywebsite.de/
(also an invalid canonial)This is important for search engines, as they will no correctly crawl the main homepage (which is most important).
Solutions:
Can be fixed via Fix #3127 redirect trailing slash using 301 statuscode #3128
& 3. Can be fixed in multiple places (I guess), you should know best. I've edited
Page.php
like this (can be improved possibly):The text was updated successfully, but these errors were encountered: