Forum Discussion
Angela_R_33237
Nimbostratus
Oct 19, 2005Simple iRule help (I hope) -- non-www to www.
How do I set up an iRule to redirect non-www requests to the www of that domain.
Example:
domain1.com --> www.domain1.com
domain2.com --> www.domain2.com
We have about 100 of these sites so ideally I'd like to be able to set up one iRule for all of them.
Any help is appreciated!
Angela
- Colin_Walker_12Historic F5 AccountYour rule would indeed be simple. It'd be something like:
when HTTP_REQUEST { if {[string tolower [HTTP::host] ] contains "www" } { pool your_poolname } else { HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" } }
- Angela_R_33237
Nimbostratus
Wonderful -- thanks! This is what I ended up using:when HTTP_REQUEST { if { ([HTTP::host] starts_with "www.") } { pool pool_name } else { HTTP::redirect "http://www.[HTTP::host][HTTP::uri]" } }
- James_Ramsey_10
Nimbostratus
Why would you use this I-Rule and not just program this rule into the application? - Colin_Walker_12Historic F5 AccountOften times people find it beneficial to add logic like this to the network layer, rather than the application itself. Not only does it provide for greater flexibility in general, but it avoids needing to schedule a code-base change for your application, which for some peeople can be quite a process.
- James_Ramsey_10
Nimbostratus
Thanks, I didn't look at it that way. - JRahm
Admin
That's the message I've tried to preach at the last two companies I've worked for, the problem I've faced is the political machine. It's all about control, and the app developers want it all.
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