1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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