Can I use [N] flag to improve this [simple] rewrite?

Discussion in 'Apache' started by okyup, Sep 28, 2008.

  1. #1
    Hello all,

    The problem is just to do a bunch of simple replaces and redirect.

    Currently I rewrite the URL over and over again but I cannot figure out how to use the [N] flag which, from what I've read, I think would be better.

    Example Input: /www/D/google/D/ca/search/D/php/Q/q/E/query
    Redirects to: http://www.google.ca/search.php?q=query

    RewriteEngine on
    
    RewriteBase /lrd
    
    # Ignore?
    RewriteRule ^(.*)/SI/.*/EI/(.*)$ /lrd/$1$2 [R,L]
    RewriteRule ^(.*)/SI/.*$ /lrd/$1 [R,L]
    
    # Replace dots
    RewriteRule ^(.*)/D/(.*)$ /lrd/$1.$2 [R,L]
    
    # Replace equals
    RewriteRule ^(.*)/E/(.*)$ /lrd/$1=$2 [QSA,R,L]
    
    # Replace ampersand
    RewriteRule ^(.*)/A/(.*)$ /lrd/$1&$2 [QSA,R,L]
    
    # Replace question marks
    RewriteRule ^(.*)/Q/(.*)$ /lrd/$1?$2 [QSA,R,L]
    
    # Redirect!
    RewriteRule ^(.*)$ http://$1 [R,L]
    Code (markup):
    Thanks in advance for any suggestions!
     
    okyup, Sep 28, 2008 IP