Forum Discussion
Damion_19248
Nimbostratus
Mar 05, 2013redirect to new domain using a part of the uri
Sample url
http://subdomain.domain.com/1050/38745/productdata-reviews/reviews.htm
301 redirect to
http://domain.com/38745/
The subdomain, the 1050 and the last portion reviews.htm...
nitass
Employee
Mar 12, 2013your message is mixed up.
is this what you are doing?
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/
if so, this is an example.
[root@ve10:Active] config b rule myrule list
rule myrule {
when HTTP_REQUEST {
if { [HTTP::host] equals "subdomain.domain.com" and [HTTP::uri] ends_with "category.htm" } {
if { [scan [HTTP::path] {/%*d/%*d/%[^-]-%*s} str] == 1 } {
HTTP::respond 301 noserver Location "http://www.domain.com/${str}/"
}
} elseif { [HTTP::host] equals "subdomain.domain.com" and [HTTP::uri] ends_with "categories.htm" } {
if { [scan [HTTP::path] {/%*d/%*d/%[^-]-%[^-]-%*s} str1 str2] == 2 } {
HTTP::respond 301 noserver Location "http://www.domain.com/${str1}-${str2}/"
}
}
}
}
[root@ve10:Active] config curl -I http://subdomain.domain.com/1050/38745/productdata-reviews/category.htm
HTTP/1.0 301 Moved Permanently
Location: http://www.domain.com/productdata/
Connection: Keep-Alive
Content-Length: 0
[root@ve10:Active] config curl -I http://subdomain.domain.com/1050/38745/productdata-moredata-reviews/categories.htm
HTTP/1.0 301 Moved Permanently
Location: http://www.domain.com/productdata-moredata/
Connection: Keep-Alive
Content-Length: 0
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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