The subdomain, the 1050 and the last portion reviews.htm is always constant. I need the subdomain to redirect to the main domain and extract the second set of numbers(38745 in the example above) from the uri and apply that as the full uri in the new 301 redirected url.
Thanks for your response. Can you tell me what is happening with %d and num? It looks like it the value for %d is created in a variable called num. I will do some digging in the morning to see if I can get some understanding on the rule you wrote.
The rule works for this case but will not match if another portion of the url changes. I have listed an example below. Is there a way to add a wildcard match for the data in between the next two slashes and is there also a way to store that next section in another variable? Thanks in advance for any help.
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.
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?
I need to apologize for a few things. I realize I wasn’t very clear in my specs and I had a typo at the end of my last comment. Both examples should have contained category.htm at the end. I appreciate the help you have given me and I am going to attempt to adjust what you have given me to fit my needs unless you happen to see this and respond before I make something work. I think I have clarified the specs below and will update when I have a working rule in place.
In the above example I am only interested in the second set of numbers(38745) in this particular example. The triggering condition needs to be the http::host and the reviews.htm at the end of http::path. The HTTP::host, the 1050 and the reviews.htm at the end of the path are all constant.
In the above example I am only interested in the third section of the http::path. It may contain a random word which I have shown as productdata or a hyphenated random word shown as productdata-moredata. The third section of the http::path will also contain -reviews which is constant and not needed in the redirected url. The triggering condition needs to be the http::host and the category.htm at the end of http::path.