Cannot redirect GET Query-String with htaccess / modrewrite

Discussion in 'Apache' started by web2crawler, Jun 4, 2009.

  1. #1
    Old url must be redirected to new url with htaccess / mod_rewrite.

    Old url : example.com/page?ref=someparam1&from=anywhere
    New url: example.com/newpage/someparam1/anywhere

    I tried with this but it does not work!



    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^page?ref=(.*)&from=(.*)$ newpage/$1/$2 [R=301,QSA,L]


    What is wrong
     
    web2crawler, Jun 4, 2009 IP
  2. jnugroho73

    jnugroho73 Peon

    Messages:
    77
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try this:

    
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    
    RewriteCond %{QUERY_STRING} ^ref=(.*)&from=(.*)$
    RewriteRule ^page$ newpage/%1/%2 [R=301,L]
    </IfModule>
    
    Code (markup):
    But I am not so sure that it is works.
     
    jnugroho73, Jun 7, 2009 IP