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]"}