-
-
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
Page extensions return duplicated content using 200 statuscode instead of 301 redirect #3130
Comments
I agree that Grav should probably be more strict on file extensions. Try using .json, it will also return html page if page doesn't support the format. This will however break backwards compatibility. |
Have you tried to set |
OK, that didn't work. I changed the configuration to accept redirect codes instead of just true/false. The fix also needs updated form plugin as the |
…irect_default_route` turned on [#3130]
Oh, and you also need to use 301 in both |
When opening a page with the |
I'm using 302 redirect code as during testing I ended up destroying my development site with neverending redirect loops by just changing a setting. Only clearing all cache from the browser helped on that as it didn't even reach the site anymore. The change should obey the new redirect setting, though? Did you try with |
I tried that and it does not work for the html postfix. Just try it out. |
Yeah, because it was missing logic for that. Develop has the latest version, it should redirect |
@NicoHood Please test it again, the implementation should be good now. If there are still issues in sitemap, I think they are specific to the plugin, but we can talk about them, too. What I've fixed here are all the duplicate pages in Grav content, such as:
Let's create a new issue for the remaining issues, please. :) |
Checkout https://bikefittingfinder.de/karte.xml it still does not redirect. (Grav 1.7.9) |
It's not supposed to. But it should be showing 404 as xml version of the page doesn't exist. Create a new issue about it. |
I found som issues with page extensions, eg
https://yourdomain.de/contact.html
:config.system.pages.types
will also work. E.g.https://yourdomain.de/contact.htmlxxx
Solution
1.: The error comes from the
Uri
class functionisValidExtension()
. The regex should be an exact match using^exact$
syntax:NicoHood@4131e9c
2.:
Uri
class functioninit()
removes the postfix from the url which causes the issue. Note thathtml
andhtm
will always return a 200, as those are set as default, no matter whatconfig.system.pages.types
contains. The reason why I even found this, is the weird behavior for the sitemap plugin, which made the sitemap available via xml and "normal" url. It causes lots of trouble for search engines, if there is duplicated content. In this case it would be best to only serve the xml file.Page processing order:
It would be best to only do the redirect if no page was found (or served by any plugin) and serve the sitemap only at
/sitemap.xml
(or whatever is configured). In order to still allow plugins to serve special.xml
files we must place the redirect after theonPageInitialized
event but beforeonPageNotFound
. A possible solution is to move the code fromUri
to thePagesProcessor
:NicoHood@ecbcdbd
The code solves the following:
sitemap.xml
on the extension uri onlyredirect_file_extensions
sitemap
and redirect atsitemap.xml
sitemap.xml
only, without any .htaccess ruleFix provided in PR #3131
The text was updated successfully, but these errors were encountered: