Forum Discussion

fwadmin's avatar
fwadmin
Icon for Altostratus rankAltostratus
Sep 18, 2023

iRule HTML Maintenance Page insert URI Value

Looking for help writing an iRule that will display, in HTML code, that the page being access has been changed.  I'm trying to figure out how to referece the requested URI in HTML since this will vary.  Below is what I have for now.  Any help is appriciated.

when HTTP_REQUEST {
HTTP::respond 200 content {
<html>
<head>
<title> This Page Has Moved </title>
</head>
<body>
<b> This Page Has Moved </b>
Links and bookmarks to example.com should be updated to example.new.com

The page you requested has moved to https://example.com/<HTTP::uri>
</body>
</html>
}
}

__PRESENT

__PRESENT

__PRESENT

__PRESENT

__PRESENT

  • Some guidance here. You can use iFiles on F5 to upload your HTML and then serve via an iRule. Easier to maintain!

    https://clouddocs.f5.com/api/irules/iFile.html

    Finally, you can use HTTP meta tags to try and have the browser auto redirect after a certain time period. Check out the previous post on this:

    https://community.f5.com/t5/technical-forum/redirect-to-another-url-after-timeout-detected/td-p/272129

    Using both resources, you should be able to set this up in no time 🙂

  • fwadmin Do you plan on owning the old domain still once it has migrated? If you will keep the old domain I would bother with this page and would just perform a 301 redirect and leave it be. You might be able to add in an additional action to add in a referer HTTP header and allow the destination server to add in a pop-up saying the site changed and when the old name will no longer be used.

  • Thanks for the reply.  Yes, totally agree, so a redirect is what was first thought, but we want users to update their bookmarks and give them some time to do that; we wont be keeping the old domain.  So is it even possible to display the URI and or URL in the html code or would it be easier to just add a popup after redirected if they went to the old URL?

    • Paulius's avatar
      Paulius
      Icon for MVP rankMVP

      fwadmin I would recommend doing the popup on the receiving server so that your iRule remains simple. Remember, just because the F5 can do it doesn't mean it's the best option.

  • fwadmin - you got some heavy hitters here ( whisperer and Paulius and even JRahm sliding in with kudos).
    If your post was solved please select *Accept As Solution* on as many replies as were helpful. It helps future-community find the good answers.

    and thanks for being part of our community.

  • Thanks for the help!  We ended up using the iFile option for the HTML portion of the page then defining a variable in the iRule for the URL and URI and refreceng those variable with $var_name.