Forum Discussion

Jnon's avatar
Jnon
Icon for Nimbostratus rankNimbostratus
Jan 26, 2018

Rewrite host header from uri on initial request only

I am trying to use an irule to manipulate host header from contents of the URI string.

 

For example: myhost.mydomain.com/myvar1/myvar2/ needs to be rewritten as myvar1.myvar2.myhost.mydomain.com/

 

I can do with the getfields and move the values, but I only want those values to be rewritten initially, to set the host, but after that, I don't want all subsequent calls to be rewritten, so /static/myjsp I don't want rewritten as static.myjsp.myhost.mydomain.com How can I scrape the initial request uri, but not subsequent, if I use an if statement and check for if uri starts_with myvar, then manipulate string. Is that going to retain my host header from the initial rewrite?

 

3 Replies

  • I'd write a cookie once you've manipulated the header. So when a subsequent request comes, you can check for the cookie, if present then you can skip the header manipulation.

     

  • Jnon's avatar
    Jnon
    Icon for Nimbostratus rankNimbostratus

    It will contain keywords that need to be moved from uri, to host header.

     

    for example hostname1/keyword1/ or hostname2/keyword2

     

    where hostname and keyword will remain constant, just the number value will change, So I should be able look for value hostname in the uri.