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.
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
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
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