Forum Discussion
Michael_Yates
Sep 27, 2012Nimbostratus
Hi Aaron,
Try this:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::uri]] {
"/" { HTTP::respond 301 Location "https://[HTTP::host]/storefront/home.ep" }
"/storefront*" -
"*/us.website-sitemap.xml" -
"*/uk.website-sitemap.xml" -
"*/ca.website-sitemap.xml" -
"*/ie.website-sitemap.xml" -
"*/au.website-sitemap.xml" -
"*/row.website-sitemap.xml" -
"*/robots.txt" { return }
default { HTTP::respond 301 Location "https://[HTTP::host]/storefront/error.ep?errorCode=404" }
}
}
Your first conditional if statement is to do nothing if the [HTTP::uri] starts with "/storefront/", but you have the same condition within your switch statement to redirect it, so I removed removed it and set the condition to only redirect if the [HTTP::uri] is "/" and collapsed the if statement.
In a switch statement you can "string tolower" the [HTTP::uri] value to set the comparison condition to a known state for comparison, add the "-glob" can be added so that you can utilize Wildcards. These together should get you the matches and actions that you are looking for.
All values in the switch statement are absolute unless you utilze a Wildcard as well. You can narrow down what your looking for like this:
starts_with = "/something*"
ends_with = "*/something.html"
contains = "*something*"
The "-" on the ends tells the condition to respond the same way as the next item, so you only have to type the action once. So all of your "/storefront", XML matches, and the robots.txt will break out of the switch statement and perform no action, but successfully prevent the default redirect.