Hi,
Apologies in advance for the newbie question!
I’d like to apply a HTTP re-write so when a user browses to blog.site.com they are redirected to www.site.com/blog/ , but blog.site.com remains in the user’s address bar.
I can currently redirect from blog.site to www.site.com/blog/ with the configuration below. Unfortunately www.site.com/blog appears in the address bar of the browser after the redirect. Is it possible to “re-write” to a new URL in the manner I’ve outlined?
when HTTP_REQUEST
…
switch [HTTP::host] {
“blog.site.com ” {
HTTP:redirect “http://www.site.com/blog/ ”
}
Hi OttimoMassimo,
There are 2 ways to ago about this.
Do you want the user who enters blog.site.com to be redirect to www.site.com/blog but still retain the blog.site.com on the user’s URL on the browser?
If so then your code would look something like this.
HTTP_REQUEST {
switch -glob [HTTP::host] {
"blog.site.com" {
HTTP::header replace Host "www.site.com"
HTTP::uri /blog [HTTP::uri]
}
}
}
or
Do you want to a user who enters blog.site.com to be redirected to www.site.com/blog , but have www.site.com/blog on the user’s URL on the browser?
If so then the code would look something like the following:
HTTP_REQUEST {
switch -glob [HTTP::host] {
"blog.site.com" { HTTP::redirect http://www.site.com/blog/ }
}
}
I hope this helps
Bhattman
thanks Bhattman. I’ll give that a try and let you know how I get on
hoolio
November 9, 2010, 4:27am
4
so yeah, got this working in the end with the following:
when HTTP_REQUEST {
…
switch [HTTP::host] {
“blog.site.com ” {
if { [HTTP::uri] equals “/” } {
HTTP::uri “/blog/”
}
pool
return
It was grafted into an existing i-rule which had a couple of re-writes before defaulting to the default pool