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

  1. Baki Goxhaj
    Posted 2 years 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
    Posted 2 years 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;
    add_action('wp', 'redirect_dotted');

Topic Closed

This topic has been closed to new replies.

About this Topic