WordPress.org

Ready to get started?Download WordPress

Forums

Dublicate content - Url works with tots and columns in it (2 posts)

  1. Baki Goxhaj
    Member
    Posted 11 months ago #

    Hi guys,

    On WP 3.6 an url with a dot, a column of many of them still works and google treates it as dublicate content. Here is an example:

    Original: http://wplancer.com/a-beginners-guide-to-the-command-line/
    With a dot: http://wplancer.com/a-beginners-guide-to-the-command-line./
    With a column: http://wplancer.com/a-beginners-guide-to-the-command-line:/
    With many dots: http://wplancer.com/a-beginners-guide-to-the-command-line........../

    All of these urls work and if mistakebly on the site, will be considered dublicate content by Google.

    Is this a bug? If not, why is this happening?

  2. Baki Goxhaj
    Member
    Posted 10 months ago #

    Sorry about my first message being full of typos. Here is a solution I came up with:

    /**
     * Fix for urls ending in dots and colons
     */
    function redirect_dotted() {
    	global $wp;
    	$current_url = home_url( $wp->request );
    	$is_dot = substr($current_url, -1, 1);
    	if( $is_dot === '.' || $is_dot === ':' ) {
    		$clean_url = rtrim( $current_url, '.:' );
    		wp_redirect( $clean_url, 301 ); exit;
    	}
    	return;
    }
    add_action('wp', 'redirect_dotted');

Reply

You must log in to post.

About this Topic