# Cannot get a simple URI redirect working

**URL:** <https://community.a10networks.com/t/cannot-get-a-simple-uri-redirect-working/433>\
**Category:** aFleX\
**Tags:** aflex\
**Created:** [March 9, 2017, 11:02am UTC](https://community.a10networks.com/t/cannot-get-a-simple-uri-redirect-working/433 "2017-03-09T11:02:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![andimorris](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@andimorris](https://community.a10networks.com/u/andimorris)\
**Post date:** [March 9, 2017, 11:02am UTC](https://community.a10networks.com/t/cannot-get-a-simple-uri-redirect-working/433/1 "2017-03-09T11:02:31Z")

</div>

Hi all,  
I’ve been searching through examples on here, the alfex github, the samples on the ACOS device, but just cannot get a simple redirect working with AFlex. Can somebody please point me in the right direction?

I’m trying to do the following  
The user visits [https://hostname.domain.com](https://hostname.domain.com) and the ACOS device redirects them to [https://hostname.domain.com/devicepage](https://hostname.domain.com/devicepage)

```auto
I currently have the following (hostname and domain are substituted for the real ones of course:
\# redirect HTTP request to device-reg page
when HTTP\_REQUEST \{

```

HTTP::respond 302 Location “[https://hostname.domain.com/devicepage](https://hostname.domain.com/devicepage)”  
}  
However the result I get is that the user gets redirected infinitely to:  
[https://hostname.domain.com/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/](https://hostname.domain.com/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/devicepage/)…

I guess I need some sort of check first to see if the URI is already devicepage/, but any time I try to implement this the AFlex syntax fails.

---

<div class="post-metadata">

**Author:** ![diederik](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@diederik](https://community.a10networks.com/u/diederik)\
**Post date:** [March 9, 2017, 11:21am UTC](https://community.a10networks.com/t/cannot-get-a-simple-uri-redirect-working/433/2 "2017-03-09T11:21:12Z")

</div>

I would do something like this:

# first check if the URI starts with “/devicepage” # if not redirect to /devicepage

when HTTP\_REQUEST { if { not ([HTTP::uri] starts\_with “/devicepage”) } HTTP::respond 302 Location “https://[HTTP::host]/devicepage[HTTP::uri]” }

---

<div class="post-metadata">

**Author:** ![andimorris](https://avatars.discourse-cdn.com/v4/letter/a/858c86/32.png) [@andimorris](https://community.a10networks.com/u/andimorris)\
**Post date:** [March 9, 2017, 1:12pm UTC](https://community.a10networks.com/t/cannot-get-a-simple-uri-redirect-working/433/3 "2017-03-09T13:12:55Z")

</div>

Thanks very much. I’ll give that a go.
