Please, I need help with apache rewrite statement.

Discussion in 'Programming' started by exodus, Sep 26, 2007.

  1. #1
    I have this url.. http://site.com/results?search_query=Deathly

    I do not have any control over results?search_query=Deathly . It is from a rss feed and instead of phrasing the rss feed urls I want just to redirect it via a htacess rewrite statment, but I am having trouble how to do the query string to a new file. So, what I need to do? Please, help.

    I am tring to use this.

    RewriteRule ^results$ search.php?site=sitequery [QSA,L]

    but that is not working.
     
    exodus, Sep 26, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    RewriteBase /
    RewriteRule ^results/(.+)$ results?search_query=$1 [L]

    That will rewrite your URLs from:
    results/Deathly -> results?search_query=Deathly
     
    krt, Sep 26, 2007 IP
  3. exodus

    exodus Well-Known Member

    Messages:
    1,900
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    165
    #3
    i found it, thanks KRT, but that was the reverse what I was looking to do. ;)

    RewriteRule ^results$ search.php?site=site [QSA,L]

    accually works, I needed to read in the search_query in the script. I forgot about that. doh!

    I just ended up redirecting to search.php and then use a 301 redirect from search.php to make it into a friendly url. Suckage I know double redirect.
     
    exodus, Sep 26, 2007 IP