.htaccess redirect

Discussion in 'Apache' started by PET, Feb 3, 2014.

  1. #1
    Hello guys,

    Google keeps indexing some of my articles in this form:

    mywebsite.com/item/my-article

    However I'm mainly using:

    mywebsite.com/item/articles/my-article

    So in a way I have duplicated content and also the first link does not show the modules I want.
    I want to create a .htaccess redirect than whenever someone joins on the first link to be automatically redirected to the second link.

    Thank You
     
    PET, Feb 3, 2014 IP
  2. elitasson

    elitasson Member

    Messages:
    49
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    RedirectMatch 301 /item/(.*)$ http://mywebsite.com/item/articles/$1
    Code (markup):
     
    elitasson, Feb 7, 2014 IP
  3. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #3
    I somehow get redirected to :

    mywebsite.com/item/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/articles/sniper-guide-dota-2
    (where mywebsite is my actually website)
     
    PET, Feb 8, 2014 IP
  4. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #4
    Anyone?
     
    PET, Feb 26, 2014 IP
  5. jeffatrackaid

    jeffatrackaid Active Member

    Messages:
    168
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    75
    #5
    Plug the normal and desired URLs into http://redbot.org/

    This will help you analyze the headers to see if you have multiple redirects for some reason.

    If you are using a CMS there could be other rewrite rules causing issues.

    Another format to try is:
    RewriteRule ^subdirectory/(.*)$ /anotherdirectory/$1 [R=301,NC,L]
    Code (markup):

    The additional items at the end tell it to use a 301, ignore case and be the last rule processed.
     
    jeffatrackaid, Feb 26, 2014 IP
  6. PET

    PET Member

    Messages:
    86
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    43
    #6
    The last one seems to work. Thanks
     
    PET, Feb 26, 2014 IP