Forum Discussion

Geoff_34657's avatar
Geoff_34657
Icon for Nimbostratus rankNimbostratus
Nov 13, 2009

HTTP 301

Hello I have a few GTMs and 8 LTMs running and I am trying to get a 301 redirect working for many of our domains from domain.com to www.domain.com. I have tried many of the iRules that I could find from doing a search. Everytime I try one it attempts to redirect but, I get a page could not be displayed. I have tried the one below and many others just like it. I do have to preserve the full URL. Do I have to run different Virtual Hosts to make this work properly? I would rather not clutter up the LTMs with extra virtual servers. I have tried the ones below and many other forms of the ones that I got off of this site.

 

 

1. when HTTP_REQUEST {

 

if {[HTTP::host] eq "domain.com" }

 

{ HTTP::redirect "http://www.domain.com[HTTP::uri]" } }

 

 

2. when HTTP_REQUEST { HTTP::respond 301 "Location" "http://www.[HTTP::host][HTTP::uri]"}

 

 

 

  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    If you use just the first rule, does it work? If not, do you see any TCL errors in /var/log/ltm?

     

     

    Aaron
  • Alright for some reason it is now working. Hmm I will have to test externally to make sure it is working properly. Thanks for the reply.