Forum Discussion
I thought I would be able to modify what you gave me to satisfy a few other parameters but apparently I don't have a good enough understanding of irule/tcl syntax to make it work. I modified your original rule to this below.
when HTTP_REQUEST { if {[HTTP::host] equals "subdomain.domain.com" and [HTTP::uri] ends_with "reviews.htm"}{ [scan [HTTP::path] /%d/%d/%s num1 num2 str] == 3}{ HTTP::respond 301 noserver Location "http://www.domain.com/${num2}/" } }
The original request got expanded and I have another condition that needs to be considered as well. In the examples below, productdata and moredata(if present) are variable.
http://subdomain.domain.com/1050/38745/productdata-reviews/category.htm Redirect to http://www.domain.com/productdata/
http://subdomain.domain.com/1050/38745/productdata-moredata-reviews/categories.htm Redirect to http://www.domain.com/productdata-moredata/
I attempted to add the additional condition to the already working rule but ran into syntactical problems. I realize this does't remove the necessary data from the string to but I was starting with it and then would add the portion to remove the data I don't need. I thought that would be easy since the data(-reviews/category.htm) is always constant. Could you help with the additional requirement and also tell me why the syntax of the rule below doesn't work?
when HTTP_REQUEST { if {[HTTP::host] equals "subdomain.domain.com" and [HTTP::uri] ends_with "reviews.htm"}{ [scan [HTTP::path] /%d/%d/%s num1 num2 str] == 3}{ HTTP::respond 301 noserver Location "http://www.domain.com/${num2}/" } elseif {[HTTP::host] equals "subdomain.domain.com" and [HTTP::uri] ends_with "category.htm"}{ [scan [HTTP::path] /%d/%d/%s num1 num2 str] == 3}{ HTTP::respond 301 noserver Location "http://www.domain.com/${str}/" } }
Edited to try and clean it up a bit