Hi,
I have a website that is available as http://www.webpage.com or http://webpage.com. I need to have all pages resolve back to the www version.
so if a visitor was to go to Checking your browser... it will redirect to http://www.webpage.com/about. This needs to happen for everypage.
Is this possible with a irule?
Thanks
Tommy
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "webpage.com") }{
HTTP::respond 301 Location "http://www.webpage.com[HTTP::uri]" Connection Close
}
}
Hi,
You can use an irule to detect if www is present and append it if not present :
when HTTP_REQUEST {
if { !([HTTP::host] contains "www.") } {
HTTP::host "www.[HTTP::host]"
}
}
Something like this:
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] eq "webpage.com" }{
HTTP::respond 301 Location "http://www.webpage.com[HTTP::uri]" Connection Close
}
}
Ha, that was quick. Thanks for that. Just one more thing…
I have some sub domains hitting that VS. IE. http://sub.webpage.com will the rule mean that www will be appended to the subdomain?
Thanks
Tom.
No, because the conditional statement with ‘eq’ (stands for equals) will only trigger for an exact match
Great, Thanks for all your help.
Tom.
when HTTP_REQUEST {
if { ! [HTTP::host] starts_with "www" } {
HTTP::redirect http://www.[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
Nice and all purpose…