# Redirects or appends

**URL:** <https://community.f5.com/t/redirects-or-appends/445>\
**Category:** Technical Forums\
**Tags:** dev, irules, devops, application-delivery\
**Created:** [December 4, 2006, 12:46am UTC](https://community.f5.com/t/redirects-or-appends/445 "2006-12-04T00:46:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Graston\_10](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mike\_Graston\_10](https://community.f5.com/u/Mike_Graston_10)\
**Post date:** [December 4, 2006, 12:46am UTC](https://community.f5.com/t/redirects-or-appends/445/1 "2006-12-04T00:46:17Z")

</div>

I was wondering I have about 20 or so redirects for urls because my development team will not put them on the servers. If a uri does not have a / at the end of it would it be possible to append this with an Irule? I tried look at this and I am using the http redirect for this and sending a redirect with the / after the uri.ex

user request the following

[https://mydomain.com/app1](https://mydomain.com/app1)

I use the redirect to

[https://mydomain/app1/](https://mydomain/app1/)

Of course this sets up 10 -15 per site

I would like to say any url that doesn’t end with / append / how ever this would cause problems for legit uri’d not needing the / at the end like ig the application sends back

[https://mydomain.com/app1/loging.asp](https://mydomain.com/app1/loging.asp)

etc…

---

<div class="post-metadata">

**Author:** ![hoolio](https://avatars.discourse-cdn.com/v4/letter/h/f6c823/32.png) [@hoolio](https://community.f5.com/u/hoolio)\
**Post date:** [December 4, 2006, 11:22am UTC](https://community.f5.com/t/redirects-or-appends/445/2 "2006-12-04T11:22:16Z")

</div>

It sounds like you’re unsure of what methodology to use for determining when to change the URI. If it’s a relatively small, known list of URIs you want to redirect, you could define them in a class and then rewrite the URI or redirect based on the class definition.

Or if it’s not a known list, you could look for any URI that has a period and then some set number of characters and append a trailing slash (ie, append a slash if there is a . followed by less than 4 characters that doesn’t end with a forward slash).

To use the first method, define a class (aka datagroup in the GUI) with the URIs you want to redirect for:

```tcl
class uris_to_redirect {
   "/app1"
   "/app2"
   "/another_uri_to_change"
}

```

Then use a rule like this to redirect clients requesting one of these URIs:

```tcl
when HTTP_REQUEST {
   if { [matchclass [string tolower [HTTP::uri]] equals $::uris_to_redirect] }{
      HTTP::redirect "http://[HTTP::host][HTTP::uri]/"
   }
}

```

Note that I didn’t test this for syntax, but I think it’s one valid example of how to handle the scenario you are describing.

Aaron
