Forum Discussion
Hi,
There are some possibilities to get this working.
e.g.
when HTTP_REQUEST {
set host [getfield [HTTP::host] : 1]
if { not ( [string tolower $host] ends_with "mycompany.com" ) } {
append host ".mycompany.com"
if { [HTTP::path] ne "/" } {
HTTP::redirect "http://$host[HTTP::uri]"
}
}
if { [HTTP::path] eq "/" } {
HTTP::redirect "http://$host/ABC"
}
}
Test #1:
# curl-apd -v --resolve application:80:172.30.30.100 http://application
* Added application:80:172.30.30.100 to DNS cache
* Rebuilt URL to: http://application/
* Hostname application was found in DNS cache
* Trying 172.30.30.100...
* Connected to application (172.30.30.100) port 80 (#0)
> GET / HTTP/1.1
> Host: application
> User-Agent: curl/7.47.1
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Moved Temporarily
< Location: http://application.mycompany.com/ABC
< Server: FRONTEND
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
* Connection #0 to host application left intact
Test #2:
# curl-apd -v --resolve application:80:172.30.30.100 http://application/mypath
* Added application:80:172.30.30.100 to DNS cache
* Hostname application was found in DNS cache
* Trying 172.30.30.100...
* Connected to application (172.30.30.100) port 80 (#0)
> GET /mypath HTTP/1.1
> Host: application
> User-Agent: curl/7.47.1
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Moved Temporarily
< Location: http://application.mycompany.com/mypath
< Server: FRONTEND
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
* Connection #0 to host application left intact
Test #3:
# curl-apd -v --resolve application.mycompany.com:80:172.30.30.100 http://application.mycompany.com
* Added application.mycompany.com:80:172.30.30.100 to DNS cache
* Rebuilt URL to: http://application.mycompany.com/
* Hostname application.mycompany.com was found in DNS cache
* Trying 172.30.30.100...
* Connected to application.mycompany.com (172.30.30.100) port 80 (#0)
> GET / HTTP/1.1
> Host: application.mycompany.com
> User-Agent: curl/7.47.1
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 302 Moved Temporarily
< Location: http://application.mycompany.com/ABC
< Server: FRONTEND
* HTTP/1.0 connection set to keep alive!
< Connection: Keep-Alive
< Content-Length: 0
<
* Connection #0 to host application.mycompany.com left intact
I hope it helps.
Regards