Forum Discussion
DaveC_53879
Jul 26, 2011Nimbostratus
Return a 301 instead of 302
I need my redirects to return a 301 instead if a 302. The Web team is unable to track the rdirected requests because they return a 302. How can I change the rule below to return a 301?
whe...
hooleylist
Jul 27, 2011Cirrostratus
HTTP::respond will not automatically set the URL in the Location header like HTTP::redirect will. So you need to set the URL as the Location header value. Also, with switch you can use - as an action if it's the same action for multiple cases. Lastly, can you double check your * wildcards to make sure you're using it to match in the correct location. The HTTP::host value will only return www.example.com if the URL is http://www.example.com/some/path.html.
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.*" -
"peoples.net" -
"peoples.com" -
"peoples.mobi" -
"peoplesfor.org" -
"peoplesfor.net" -
"peoplesfor.com" -
"speople.net*" -
"speople.org" -
"speople.com" -
"people.net" -
"people.com" -
"*-people.org" -
"*-people.net" -
"*-people.com" -
"*-peoples.org" -
"*-peoples.net" -
"*-peoples.com" -
"people.org" { HTTP::respond 301 Location "http://peoples.org[HTTP::uri]" }
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects