Forums

[resolved] 301 Redirect Duplicate Content (4 posts)

  1. Tzeapa
    Member
    Posted 8 months ago #

    Hello,

    I'm trying to remove duplicate content to my website by 301 redirects.

    I'm currently having a lot of paged articles. I managed to 301 redirect links like http://domain.com/some-article/ to http://domain.com/some-article by using this code:

    <IfModule mod_rewrite.c>
    RewriteCond %{HTTP_HOST} ^(www.)?domain.com\.com$ [NC]
    RewriteRule ^(.+)/$ http://domain.com/$1 [R=301,L]
    </ifmodule>

    The issue is that http://domain.com/some-article/1 and http://domain.com/some-article both return 200 OK status and deliver the exact same content.

    The second issue is that http://domain.com/some-article/2 and http://domain.com/some-article/2/ both return 200 OK status. Although WordPress rewrites the URLs they aren't 301 redirected.

    Any info on the matter would be greatly appreciated.

  2. Tzeapa
    Member
    Posted 8 months ago #

    I've done all of the above (except for some-article/1 to some-article redirect) using this inside .htaacces

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} (.*)$
    RewriteRule ^(.+)/$ http://domain.com/$1 [R=301,L]

    Now I only need to redirect http://domain.com/some-article/1 to http://domain.com/some-article

  3. tomaltman
    Member
    Posted 8 months ago #

    You may give a plugin called Redirection a try. it is not great if you have a very large number (hundreds) of redirects...but it is a very good plugin.

    Good luck
    :) tom

  4. Tzeapa
    Member
    Posted 8 months ago #

    I already managed to find a solution :D

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} (.*)$
    RewriteRule ^(.+)/1$ http://benchmark3d.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} (.*)$
    RewriteRule ^(.+)/1/$ http://benchmark3d.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_URI} (.*)$
    RewriteRule ^(.+)/$ http://benchmark3d.com/$1 [R=301,L]

    Just Trial end Error

Reply

You must log in to post.

About this Topic