Important note

The EdgeRules feature is available only on Enterprise plans.

  1. Background

    Some user agents (web browsers) act differently than others. In this example we will show you how to create a redirect if the end user is using a iPhone or Android smartphone.

  2. Rule

  3. Curl Before Rule

    curl -A "Android" -I
        HTTP/1.1 200 OK
        Server: NetDNA-cache/2.2
        X-Cache: HIT
        Accept-Ranges: bytes
  4. Curl After Rule

    curl -A "Android" -I
        HTTP/1.1 301 Moved Permanently
        Date: Sat, 19 Jan 2013 01:11:29 GMT
        Content-Type: text/html
        Content-Length: 184
        Connection: keep-alive
        Server: NetDNA-cache/2.2
  5. Regular Expression Visualization

  6. Resulting Nginx Configuration Block

     location = /ua-test.html {
        if ($http_user_agent ~* (Android|iPhone)) {
        rewrite ^ permanent;