• Resolved MGF

    (@mygayflatmate)


    I’m replacing every url that contains “for-rent” to “room”.

    the replacement worked well. But the old URL are not redirecting to the new URL.

    Check the video.

    kind regards,
    A

Viewing 1 replies (of 1 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @mygayflatmate,

    As far as I can see, the original listing permalinks were different, and you have changed them to “for-rent/LISTING ID” format. Only the original URLs are redirected to custom permalinks in the free version of the plugin. In the article below, you may learn more about native/initial URIs and canonical redirects.
    https://permalinkmanager.pro/docs/plugin-settings/canonical-redirects/#4-how-does-canonical-redirect-affects-custom-permalinks

    All URL modifications are not kept anywhere as extra redirects. This functionality is available only in Pro version:
    https://permalinkmanager.pro/docs/plugin-settings/old-custom-permalinks-redirect/

    Because your URLs end in post IDs, you may use your own fallback function to force a redirect if no post is detected but the ID extracted from the URL is used by post.

    function pm_redirect_post_uris_from_404() {
    	global $wp, $wpdb;
    
    	if(is_404()) {
    		$slug = basename($wp->request);
    
    		// Check if the slug is numeric ID
    		if(is_numeric($slug)) {
    			$element = $wpdb->get_row($wpdb->prepare("
    				SELECT * FROM {$wpdb->posts}
    				WHERE ID = %d
    				AND post_status = 'publish'
    				",
    				$slug
    			));
    
    			if(!empty($element->ID)) {
    				$url = get_permalink($element->ID);
    
    				wp_safe_redirect($url, 301);
    				exit();
    			}
    		}
    	}
    }
    add_action('template_redirect', 'pm_redirect_post_uris_from_404', 1);
Viewing 1 replies (of 1 total)
  • The topic ‘old url not redirecting to new url’ is closed to new replies.