Forum Discussion

Justin_Kalb_440's avatar
Icon for Nimbostratus rankNimbostratus
Nov 08, 2010

Irule to change page extension

Sorry this is a total noob post and if i am reposting please bear with me.



I am completely new to rewriting and in a situation where i am not able to directly interface with the f5. I am working with the following code:



when HTTP_REQUEST { if { [HTTP::uri] contains ".php" } { HTTP::redirect [HTTP::host] [HTTP::uri [string map -nocase {".php" ".html"} [HTTP::uri]]] } 


The intent is to remap all resuests for to Can anyone shed light on the simplest way of making this redirect?






4 Replies

  • George_Watkins_'s avatar
    Historic F5 Account
    Hi Justin,



    Man! For not having access to a BIG-IP, you were almost dead on. I modified it slightly and this is what I came up with:



    when HTTP_REQUEST { 
    if { [HTTP::uri] contains ".php" } {
    HTTP::redirect http://[HTTP::host][string map -nocase {".php" ".html"} [HTTP::uri]]



    You should download a copy of LTM VE ( It is free and runs on VMWare ESXi, Workstation, or Player. I use it extensively for testing iRule code and configurations involving LTM. Hope this helps,



  • As George suggests, LTM VE would be a great way to test this.

    Do you want the user to see the change to the file type? If so, then a redirect would work fine. If you want the change to be transparent to the user, you could change the redirect to a rewrite:

    when HTTP_REQUEST { 
       if { [HTTP::path] ends_with ".php" } {
          HTTP::uri [string map -nocase {".php" ".html"} [HTTP::path]]