Support » Plugin: Permalink Manager Lite » Duplicate URLs lowercase and uppercase

  • Resolved moverable


    We created custom URIs for slugs in category /x1/ and /x2/.
    Every post under these categories are now manually set to uppercase (example /x1/ABC1D).

    We have to have these uppercase (various reasons for this)

    The problem is the both URLs are now accessible /x1/abc1d and /x/ABC1D, showing the same content and causing SEO duplicate issues since google thinks these are two different pages.

    How do we force redirect visitors who go to lowercase version to the uppercase version automatically?

    Thank you!!

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


    Hi @moverable,

    Unfortunately there is no out-of-box solution available, but you can trigger the canonical redirect by using the below code snippet:

    function pm_allow_lowercase_redirect() {
    	global $permalink_manager_uris, $pm_query, $wp, $wp_query;
    	if ( ! empty( $pm_query['id'] ) && is_singular() ) {
    		$element_id = $pm_query['id'];
    		if ( is_numeric( $element_id ) && ! empty( $permalink_manager_uris[ $element_id ] ) ) {
    			$custom_uri    = $permalink_manager_uris[ $element_id ];
    			$requested_uri = $pm_query['uri'];
    			if ( strcasecmp( $custom_uri, $requested_uri ) === 0 && ( $custom_uri !== $requested_uri ) ) {
    				$wp_query->query_vars['do_not_redirect'] = 0;
    add_action( 'template_redirect', 'pm_allow_lowercase_redirect', 0 );
    add_filter( 'permalink_manager_force_lowercase_uris', '__return_false', 100 );

    Please keep in mind that this only applies to posts, pages, and custom post items with custom permalinks set by the Permalink Manager plugin.

    As a result, the WordPress core codebase does not have this functionality included and the fact that this is a custom code snippet, I cannot guarantee that it will function properly in every server environments.

    Best regards,

    Thread Starter moverable


    It seems it worked. Thank you very much!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.