Support » Plugin: AMP for WP - Accelerated Mobile Pages » Problems after changing permalinks structure

  • Hi!

    I changed permalinks structure of my blog. Over all AMP pages functioned well but there were issues with redirects from old permalink to new one. WordPress makes these redirects automatically work but for AMP pages the redirect is done to regular page.

    My simple solution to problem is this primitive piece of code I’m using in custom MU plugin:

    
    function redirect_fix_for_amp($location, $int1)
    {
    	$requestParts = explode('?', $_SERVER["REQUEST_URI"], 2);
    
    	if(substr(strtolower($requestParts[0]),strlen($requestParts)-5)=='/amp/')
    	{
    		$redirectParts = explode('?', $location, 2);
    		$newLocation = $redirectParts[0] . 'amp/';
    		if(count($redirectParts) > 1)
    		{
    			$newLocation .= '?' . $redirectParts[1];
    		}
    		
    		return $newLocation;
    	}
    	
    	return $location;
    }
    add_filter('wp_redirect', 'redirect_fix_for_amp',10, 3);
    

    Please add this functionality to your plugin if possible. Tne code above works only with AMP URL-s ending with /amp/.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problems after changing permalinks structure’ is closed to new replies.