Forum Discussion

Brendan_Deasy_8's avatar
Brendan_Deasy_8
Icon for Nimbostratus rankNimbostratus
Apr 24, 2007

URL-uri rewite - pass uri as wildcard to url parameter

Hello,

 

 

I need to write a rule that will rewrite a uri and pass it as a url parameter.

 

 

Example:

 

 

www.company/foo

 

www.company/bar

 

 

I need the rule to output as:

 

 

www.company.com/newuri/index?page=foo

 

www.company.com/newuri/index?page=bar

 

 

Thanks in advance!

 

Brendan Deasy

1 Reply

  • You can get and set the URI with HTTP::uri. If you want to change the host, you can use HTTP::header replace Host NEW_HOST.

    Here's an example:

    
    when HTTP_REQUEST {
        set new URI
       HTTP::uri /newuri/index?page=[HTTP::uri]
       log local0. "new uri: /newuri/index?page=[HTTP::uri]"
        set new Host header
       HTTP::header replace Host www.company.com
       log local0. "replaced Host header"
    }

    Depending on your requirements, you might want to add in logic to check that the original requested URI should be rewritten to the form "/newuri/index?page=ORIGINAL_URI".

    Aaron