Edit aFlex redirect rule to play a bit nicer with URL

Community Forum Forums Thunder and AX Series aFleX Edit aFlex redirect rule to play a bit nicer with URL

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by avatar armundo_m 3 years, 8 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #4431
    avatar
    armundo_m
    Member

    Hello,

    I am hoping there is an aFlex solution for what I’m trying to do – I currently have an aFlex rule that is:

    when HTTP_REQUEST {
    if { not([HTTP::host] equals “www.mydomain.com”)} {
    HTTP::respond 301 “Location” “http://www.mydomain.com”
    }
    }

    Basically saying that if the user does not type http://www., a hard redirect will automatically happen and go to http://www.mydomain.com

    This rule must remain the primary rule in my virtual service set, however this rule is conflicting with
    an additional rule I am trying to add.

    The additional rule that I am trying to get working is that when a user visits mydomain.com/abc-xyz, the
    rule should redirect to http://wwww.mydomain.com/abc-xyz.

    I have tried several different aFlex entries, however the rule listed above will automatically redirect to
    http://www.mydomain.com, and does not keep the /abc-xyz.

    I am willing to alter the original rule listed above to accomplish this if that is possible, as long as the original function is
    also retained.

    #4435
    avatar
    dshin
    Member

    So basically, both your rules will involve the client to go to “http://www.mydomain.com” but your additional rule is that it keeps the uri. Is that correct? Would it be possible to just add [HTTP::uri] to the end of the 301 response?

    when HTTP_REQUEST {
    if { not([HTTP::host] equals “www.mydomain.com”)} {
    HTTP::respond 301 “Location” “http://www.mydomain.com[HTTP::uri]”
    }
    }

    Please try it and let me know if that works for you.

    Genard

    #4437
    avatar
    armundo_m
    Member

    That did indeed work! Such a simple edit! Thanks!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

Comments are closed.