301 Redirect with ? in the url

Discussion in 'Apache' started by Foxxy, May 20, 2014.

  1. #1
    I'm seeing a lot f 404 pages in WMT with urls like:

    mysite.com/category/folder/child-folder/tagkeyword?start=20
    mysite.com/category/folder/child-folder/tagkeyword?start=30
    mysite.com/category/folder/child-folder/tagkeyword?start=40

    To fix the problem, I need to remove the folder and child folder so that I end up with:

    mysite.com/category/tagkeyword?start=20

    I try entering the following into htaccess but it does not work:

    redirect 301 /category/folder/child-folder/tagkeyword?start=20 /category/tagkeyword?start=20
    Code (markup):
    I'm pretty sure it is the question mark causing me problems. How do I get around this?
     
    Foxxy, May 20, 2014 IP
  2. Tier_net

    Tier_net Active Member

    Messages:
    35
    Likes Received:
    5
    Best Answers:
    3
    Trophy Points:
    58
    #2
    Hello,
    Try this instead?

    redirect 301 /category/folder/child-folder/tagkeyword\?start=20 /category/tagkeyword?start=20

    A "?" in a regex is considered a wildcard for any character.. Not sure if this is the problem here though..
     
    Tier_net, May 20, 2014 IP
  3. Foxxy

    Foxxy Active Member

    Messages:
    465
    Likes Received:
    46
    Best Answers:
    0
    Trophy Points:
    90
    #3
    When I try adding the backslash before the question mark I get a 500 error, which is the same thing I get without the backslash. Thanks anyway though.
     
    Foxxy, May 20, 2014 IP