.htaccess Redirect 301 rule - please help me!

Discussion in 'Apache' started by futura09, Jul 30, 2009.

  1. #1
    Hi,
    I'm setting 301 Redirects in the .htaccess of a website.

    I need to redirect a dynamic url like this:
    http://www.mysite.com/en/details_links_en.php?catnavid=7639&navpage=1
    to http://www.mysite.com
    The catnavid and the navpage values can change.

    I've put in the .htaccess:
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ en/details_links_en\.php\?catnavid(.*)&navpage=(.*)\ HTTP/
    RewriteRule ^en/details_links_en\.php$ http://www.mysite.com? [R=301,L]

    But it doesn't work.
    Can anyone help me?
    Where am I going wrong? :confused:

    Thanks!
     
    futura09, Jul 30, 2009 IP
  2. gostats

    gostats Peon

    Messages:
    325
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    THE_REQUEST is the HTTP request header.
    example [GET /index.php HTTP/1.1]
    Is there a reason that you are wanting to test against GET/POST/HEAD etc?

    If not, then perhaps you want to use
    REQUEST_URI

    I might suggest changing your RewriteCond to a different regex such as:
    RewriteCond %{REQUEST_URI} en/details_links_en\.php\?catnavid=(.*)&navpage=(.*)
    RewriteRule ^(.*)$ http://www.mysite.com? [R=301,L]

    I didn't test the above, so please work carefully.

    I would be interesting in knowing if that fixes your issue.
     
    gostats, Jul 30, 2009 IP
  3. futura09

    futura09 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi, thanks for your reply.
    I've tested your code but unfortunately it still doesn't work.
    I can't understand why....
    Could you suggest me a fix or give me a hint?

    Thank you!
     
    futura09, Jul 31, 2009 IP
  4. gostats

    gostats Peon

    Messages:
    325
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Um, I can suggest perhaps send me a PM with your implementation and the URL you are trying?
     
    gostats, Aug 8, 2009 IP