Forum Discussion
Cliff_Airhart_1
Nimbostratus
Apr 07, 2005Redirecting HTTP to a website using iRule
I am trying to setup an iRule that will provide the following:
When a user types the following URL ( http://www.company.com ) it will be redirected automaticall to
http://www.company.com:50000/dir
We don't want the users to type the service and extra directory path. We are running a BIGIP 540 with version 4.6.2
Any assistance would be greatly appreciated!
Thanks,
Cliff Airhart
Network Engineer
Spectrolab
cairhart@spectrolab.com
- bknotwell_12713Historic F5 AccountDo you need something more than the following:
b rule myredir show RULE myredir { if (http_host == "www.company.com") { redirect to "http://www.company.com:5000/dir" } else { discard } }
- bknotwell_12713Historic F5 AccountSorry about the confusion, the initial command was the output of a rule show.
b rule myredir '{if(http_host == "x.xx.xxx") { redirect to "http://x.xx.xxx:80/index.shtml" }' b virtual 192.168.1.22:0 { use rule myredir }
bash-2.05b$ telnet 192.168.1.22 6666 it could be any port Trying 192.168.1.22... Connected to 192.168.1.22. Escape character is '^]'. GET / HTTP/1.0 Host: x.xx.xxx HTTP/1.0 302 Found Location: http://x.xx.xxx:80/index.shtml Connection: close Connection closed by foreign host. bash-2.05b$
- Cliff_Airhart_1
Nimbostratus
When I insert the below syntax into the Rule text section in the Configuration Utility I recieve an error: - bknotwell_12713Historic F5 AccountI've included my shell interaction below:
knotwell:~ b rule myredir1 '{ if(http_host == "x.xx.xxx") { redirect to "http://xxx.xxx:80000/dir" }}' knotwell:~ b virtual 192.168.1.222:0 { use rule myredir1 } knotwell:~
- I just tried out this rule on 4.6.2 and it loaded properly.
if (http_host == "www.company.com") { redirect to "http://www.company.com:5000/dir" } else { discard }
bigpipe rule myredir '{if (http_host == "www.mycompany.com") { redirect to "http://www.company.com:5000/dir" }}'
- bknotwell_12713Historic F5 AccountAssumption: www.company.com resolves to the unused ip you've chosen and the resolution to it has a vip as well.
- Cliff_Airhart_1
Nimbostratus
I got it working. Thank you for your help!
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