-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathurl-rewrite-switch.tcl
48 lines (46 loc) · 1.31 KB
/
url-rewrite-switch.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#
# Copyright 2014, Mischa Peters <mpeters AT a10networks DOT com>, A10 Networks.
# Version 1.0 - 20111213
#
# aFleX script for URL Rewrite and service-group
# selection.
#
# Scalability of this aFleX is unknown.
#
#
when RULE_INIT {
set ::DEBUG 0
}
when HTTP_REQUEST {
set URI [string tolower [HTTP::uri]]
switch -glob $URI {
"/shopping*" {
HTTP::respond 301 Location "http://shopping.example.com"
if { ($::DEBUG == 1) } { log "Redirected: $URI" }
}
"/jobb*" {
regsub -all "/jobb/?" $URI "/" newuri
HTTP::uri $newuri
pool sg-pool
if { ($::DEBUG == 1) } { log "URI Rewrite for $URI" }
}
"/static/0*" {
regsub -all "/static/0/?" $URI "/" newuri
HTTP::uri $newuri
pool sg-pool0
if { ($::DEBUG == 1) } { log "URI Rewrite for $URI" }
}
"/static/1*" {
regsub -all "/static/1/?" $URI "/" newuri
HTTP::uri $newuri
pool sg-pool1
if { ($::DEBUG == 1) } { log "URI Rewrite for $URI" }
}
"/static/2*" {
regsub -all "/static/2/?" $URI "/" newuri
HTTP::uri $newuri
pool sg-pool2
if { ($::DEBUG == 1) } { log "URI Rewrite for $URI" }
}
}
}