Title: Problems after changing permalinks structure
Last modified: May 20, 2018

---

# Problems after changing permalinks structure

 *  [gpeipman](https://wordpress.org/support/users/gpeipman/)
 * (@gpeipman)
 * [8 years ago](https://wordpress.org/support/topic/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)

 *  Plugin Contributor [ampforwp](https://wordpress.org/support/users/ampforwp/)
 * (@ampforwp)
 * [8 years ago](https://wordpress.org/support/topic/problems-after-changing-permalinks-structure/#post-10302376)
 * Hello [@gpeipman](https://wordpress.org/support/users/gpeipman/)
 * Thank you for the sharing this with one!
 * Can you please share the old and new permalink structure so I can recreate the
   issue on my end.
 *  Thread Starter [gpeipman](https://wordpress.org/support/users/gpeipman/)
 * (@gpeipman)
 * [8 years ago](https://wordpress.org/support/topic/problems-after-changing-permalinks-structure/#post-10302544)
 * Hi!
 * Yes, sure, I can share. Here we go:
 * Old structure: [http://gunnarpeipman.com/2018/05/sample-post/](http://gunnarpeipman.com/2018/05/sample-post/)
   
   New structure: [http://gunnarpeipman.com/category-name/sample-post/](http://gunnarpeipman.com/category-name/sample-post/)
 * By example: [http://gunnarpeipman.com/aspnet/blazor-pager-component/](http://gunnarpeipman.com/aspnet/blazor-pager-component/)
 * I’m not 100% sure if this is the issue with vanilla installation of things. I
   have also some SEO plug-ins installed but these doesn’t seem to involve to redirects.
 *  Plugin Contributor [ampforwp](https://wordpress.org/support/users/ampforwp/)
 * (@ampforwp)
 * [8 years ago](https://wordpress.org/support/topic/problems-after-changing-permalinks-structure/#post-10303060)
 * Hello [@gpeipman](https://wordpress.org/support/users/gpeipman/)
 * Thank you for the information.
 * Will try to recreate the issue on my end and will fix it if this issue is occurring
   on my end.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems after changing permalinks structure’ is closed to new replies.

 * ![](https://ps.w.org/accelerated-mobile-pages/assets/icon-256x256.png?rev=1693616)
 * [AMP for WP - Accelerated Mobile Pages](https://wordpress.org/plugins/accelerated-mobile-pages/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/accelerated-mobile-pages/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/accelerated-mobile-pages/)
 * [Active Topics](https://wordpress.org/support/plugin/accelerated-mobile-pages/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/accelerated-mobile-pages/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/accelerated-mobile-pages/reviews/)

## Tags

 * [permalink](https://wordpress.org/support/topic-tag/permalink/)
 * [redirect](https://wordpress.org/support/topic-tag/redirect/)

 * 3 replies
 * 2 participants
 * Last reply from: [ampforwp](https://wordpress.org/support/users/ampforwp/)
 * Last activity: [8 years ago](https://wordpress.org/support/topic/problems-after-changing-permalinks-structure/#post-10303060)
 * Status: not a support question