-
Notifications
You must be signed in to change notification settings - Fork 385
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
_wp_old_slug redirect loses ?amp on posts with changed slugs #3357
Comments
I'm not seeing this when testing in my development environment. What I'm doing to test:
I successfully get redirected to the expected URL: |
@westonruter I was able to reproduce @archon810 bug and then navigating to old post slug with ?amp I've got redirected first to the old slug without ?amp and then to new slug. |
Does enabling Are there any adverse effects for us, given that we didn't implement specific support for 404 AMP pages? |
Yes, enabling |
The "redirect on 404" is directly tied to the 404 template, as it seems. We should try to hook into the redirect mechanism, it is probably just stripping unknown query vars. |
I think this should do the trick: diff --git a/amp.php b/amp.php
index b11d3862..a7aa9d2b 100644
--- a/amp.php
+++ b/amp.php
@@ -734,14 +734,13 @@ add_action( 'plugins_loaded', '_amp_bootstrap_customizer', 9 ); // Should be hoo
* If post slug is updated the amp page with old post slug will be redirected to the updated url.
*
* @since 0.5
- * @deprecated This function is irrelevant when 'amp' theme support is added.
*
* @param string $link New URL of the post.
* @return string URL to be redirected.
*/
function amp_redirect_old_slug_to_new_url( $link ) {
- if ( is_amp_endpoint() && ! amp_is_canonical() ) {
+ if ( ! amp_is_canonical() && false !== get_query_var( amp_get_slug(), false ) ) {
if ( current_theme_supports( AMP_Theme_Support::SLUG ) ) {
$link = add_query_arg( amp_get_slug(), '', $link );
} else { The problem is that |
Wouldn't you still need |
Ah, nevermind, this is probably not used in that case then. |
For now I've enabled the checkbox, though this sort of "broke" our 404s on AMP: https://www.androidpolice.com/2019/09/25/asdf/?amp vs https://www.androidpolice.com/2019/09/25/asdf/. |
We rolled out a fixed version of the 404 page for AMP now to mitigate this. |
The broken 404 will be fixed in 1.3 via #3039. |
This needs to be re-checked for whether it is still an issue. |
…paired_amp_unavailable Fixes #3357
QA Passed As noted in #2062 (comment), I tried creating a post with a slug So this is working as expected. |
Hi,
We're using AMP WP 1.2.2, and I noticed several issues in Search Console's AMP section. The issue is when a post's slug is changed and
_wp_old_slug
kicks in, the redirect loses?amp
and ends up redirecting to a non-AMP page.For example:
https://www.androidpolice.com/2019/09/25/google-engineer-web-app-spot-satellites-bare-eyes/?amp
gets redirected to
https://www.androidpolice.com/2019/09/25/google-app-satellites-steet-view/
instead of
https://www.androidpolice.com/2019/09/25/google-app-satellites-steet-view/?amp
I noticed similar fixed issues but seems like there may be a regression - possibly because they were dealing with
/amp
instead of?amp
: #560, #649.The text was updated successfully, but these errors were encountered: