• Hi,

    Redirection doesn’t work for url’s containing unicode characters such as: Ő, Ɣ, 漢字 or even 💋

    Essentially it appears that redirection is limited to the basic ASCII set.

    This is using the WordPress redirect method.

    • This topic was modified 8 years, 10 months ago by redbullpeter.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter redbullpeter

    (@redbullpeter)

    OK got a fix for you:

    --- redirect.php.old    2017-08-02 13:23:49.305649301 +0000
    +++ redirect.php        2017-08-02 13:13:11.505904205 +0000
    @@ -82,7 +82,7 @@
                            FROM {$wpdb->prefix}redirection_items INNER JOIN {$wpdb->prefix}redirection_groups ON
                            {$wpdb->prefix}redirection_groups.id={$wpdb->prefix}redirection_items.group_id AND {$wpdb->prefix}redirection_groups.status='enabled'
                            AND {$wpdb->prefix}redirection_groups.module_id=%d WHERE ({$wpdb->prefix}redirection_items.regex=1
    -                       OR {$wpdb->prefix}redirection_items.url=%s)", WordPress_Module::MODULE_ID, $url );
    +                       OR {$wpdb->prefix}redirection_items.url=%s)", WordPress_Module::MODULE_ID, urldecode($url) );
     
                    $rows = $wpdb->get_results( $sql );
                    $items = array();
    Plugin Author John Godley

    (@johnny5)

    Thanks. I’m adding a note here that Redirection expects you to encode the URL when you create the redirect (this is just how the plugin worked when it was created). The above fix will break any encoded URLs in existing installations.

    My long term goal is to to migrate all pre-encoded URLs so that the user doesn’t need to worry about the encoding, and the above fix will then be appropriate. This could impact sites so it’s something I will need to be careful with.

    Thread Starter redbullpeter

    (@redbullpeter)

    OK this should deal with backwards compatibility:

    $sql = $wpdb->prepare( "SELECT {$wpdb->prefix}redirection_items.*,{$wpdb->prefix}redirection_groups.position AS group_pos
    			FROM {$wpdb->prefix}redirection_items INNER JOIN {$wpdb->prefix}redirection_groups ON
    			{$wpdb->prefix}redirection_groups.id={$wpdb->prefix}redirection_items.group_id AND {$wpdb->prefix}redirection_groups.status='enabled'
    			AND {$wpdb->prefix}redirection_groups.module_id=%d WHERE ({$wpdb->prefix}redirection_items.regex=1
    			OR {$wpdb->prefix}redirection_items.url=%s
    			OR {$wpdb->prefix}redirection_items.url=%s)", WordPress_Module::MODULE_ID, $url, urldecode($url) );

    Essentially just adding an additional conditional statement for the newer use case. You can then remove the older use case condition once you think it’s been “long enough”.

    • This reply was modified 8 years, 10 months ago by redbullpeter.
    Plugin Author John Godley

    (@johnny5)

    Sure, there are solutions. I’m going to tread carefully as the impact could be great.

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

The topic ‘Does not redirect for unicode characters’ is closed to new replies.