Accelerated-mobile-pages: Redirection issue when visiting AMP version after clicking Non-AMP link in Header (0.9.97.33)

Created on 6 Mar 2019  路  12Comments  路  Source: ahmedkaludi/accelerated-mobile-pages

Ref: https://secure.helpscout.net/conversation/780551834/55800?folderId=1914712

For better understand user has recorded a video and also the issue is recreated on a local server.

NEXT UPDATE HIGH] bug

Most helpful comment

Still Facing the issue on my local server after clicking Non-AMP link in Header after that it still not redirecting to AMP

All 12 comments

The user who has detected the problem is me. It only works well in version 0.9.97.31, in the rest of updates until 0.9.97.39, the plugin is unstable in relation to redirects. Thanks for the interest

I had the same problem with Non-AMP links and after lots of trying I solved it
by deleting these functions from the file includes/redirect.php

// #1947 when nonamp=1 it should redirect to original link so that google
function ampforwp_custom_query_var($vars) {
$vars[] = 'nonamp';
return $vars;
}
add_filter( 'query_vars', 'ampforwp_custom_query_var' );
add_action( 'template_redirect', 'ampforwp_redirect_to_orginal_url' );
function ampforwp_redirect_to_orginal_url(){
$go_to_url = "";
$url = "";
$url = ampforwp_amphtml_generator();
$nonamp_checker = get_query_var( 'nonamp');
if($url){
if( $nonamp_checker == 1 ){
$go_to_url = remove_query_arg('nonamp', $url);
$go_to_url = explode('/', $go_to_url);
$go_to_url = array_flip($go_to_url);
unset($go_to_url['amp']);
$go_to_url = array_flip($go_to_url);
$go_to_url = implode('/', $go_to_url);

  wp_safe_redirect( $go_to_url, 301 );
  exit;
}
else{
  return;
}

}
return;
}
// #1947 ends here

* review *

  • [x] Kaleem

  • [x] Imran

I just updated to see 0.9.97.44.2, I deleted the functions that you indicate in github

GitHub

and the problem persisted after deleting the cache and Opcache of my servant, as well as that of the mobile browsers CMS browser, crhome and firefox. I'm still waiting for help. It only works with version 0.9.97.31

deleting the functions worked for me until the version 0.9.97.39 and the site still working but I didn't upgrade the version anymore the project ended. you can check the site https://www.pack-und-wasch.de
try to set the link in header or footer. if still not working search for some kind of plugins conflict in case nothing found then u need to take a look in the core files and check each function() has something to do with the redirections of your site was it for the AMP or the non-AMP
so I was able to solve it. hope you found the solution!

0.9.97.39

Dear friend, after a rocback to version 0.9.97.39 and delete the functions as you indicate, my website came back to work correctly. As you did not keep updating, the cause that the new versions do not work is that you overwrite them when you update them, the code that you deleted. At the moment I leave it in the view 0.9.97.39 as you, waiting for the authors of the plugin to correct the error. Thank you.

Still Facing the issue on my local server after clicking Non-AMP link in Header after that it still not redirecting to AMP

I think the issue does not get fixed because the site does not redirect to AMP version again once redirected to the non-amp version using the non-AMP link in Header.

@Zabi09 is there any reason for adding an extra query to resolve this issue?

Not working properly when Homepage option is enabled, and also when it is turned off, redirect it again back to normal link

Ready to merge.

Pushed in 0.9.97.58

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MohammedKaludi picture MohammedKaludi  路  8Comments

satriaenur picture satriaenur  路  4Comments

prayagverma picture prayagverma  路  3Comments

HaripriyaHari picture HaripriyaHari  路  7Comments

chaselivingston picture chaselivingston  路  5Comments