Forum Discussion
Heidi_35827
Nimbostratus
Nov 08, 2011iRule for HTTP redirect from retired URL to new URL
I'm new to iRules and could use some help. I think I have a pretty basic question but I'm not finding the answer after a few searches in DevCentral.
Here is what I'm trying to do....we have a web site that is retiring and will be replaced with a new site. We would like to do an http redirect to the new site when someone hits the old URL. Both sites are HTTPS. We want the URL in the users address bar to change to the new address.
Basic functionality: User goes to https://www.oldsite.com. Redirect is sent to send user to https://www.newsite.com
I've tried some basic HTTP redirect iRules, but none are working for me.
Do I need to use something other than a basic HTTP profile in the vserver I'm applying the iRule to?
Is the HTTPS adding some complexity that I'm not accounting for?
19 Replies
- Kevin_Stewart
Employee
If you don't want the /survey-soutions URI, then don't add the [HTTP::uri] string at the end of the HTTP::respond command. - eyambej72_11653
Nimbostratus
Thank You. - Michael_Wherry_
Nimbostratus
In these examples we always see that you use the old site as a reference. What if you simply want to say. "Anything that comes to this address" forward to this URL.
Thanks - Kevin_Stewart
Employee
That's the very basis of the built-in HTTP-to-HTTPS iRule. It simply redirects without a conditional expression. - Ethan_28095
Nimbostratus
need help with 301 redirect for thisif i have 10 domains
i try to redirect like below
Old URL: http://www.[domains].comNew URL: http://abc.[domains].comthank youwhen HTTP_REQUEST {if { [string tolower [HTTP::host]] starts_with "www" } { HTTP::respond 301 Location "-----" } } - Arie
Altostratus
Try this:HTTP::respond 301 Location [string replace [HTTP::host] 0 3 "abc."][HTTP::uri] - nitass
Employee
just another example.
e.g.[root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { if { [HTTP::host] starts_with "www" } { HTTP::respond 301 noserver Location "http://[string map {www abc} [HTTP::host]][HTTP::uri]" } } } [root@ve10:Active] config curl -I http://www.foo.com/something HTTP/1.0 301 Moved Permanently Location: http://abc.foo.com/something Connection: Keep-Alive Content-Length: 0 [root@ve10:Active] config - Ashish_Ram_Tak1
Nimbostratus
Dear Team,
I require one redirection rule for below requirement.
1) http://example.in
2) http://www.example.in
3) https://www.example.in
to http://home.example.co.in
i have below iRule
when HTTP_REQUEST {
if { [string tolower [HTTP::host]] contains "example.in" } {
HTTP::redirect "http://home.example.co.in"
}
}
will it work, or do have to made any changes in it.
Ashish Takawale. - nitass
Employee
will it work, or do have to made any changes in it.yes, it could work. if you want more specific, switch case can also be used.
e.g.[root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { switch [HTTP::host] { "example.in" - "www.example.in" { HTTP::redirect "http://home.example.co.in[HTTP::uri]" } } } } [root@ve10:Active] config curl -IL http://example.in/something HTTP/1.0 302 Found Location: http://home.example.co.in/something Server: BigIP Connection: Keep-Alive Content-Length: 0 HTTP/1.1 404 Not Found Date: Wed, 19 Jun 2013 14:14:19 GMT Server: Apache/2.2.3 (CentOS) Connection: close Content-Type: text/html; charset=iso-8859-1
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