Hello Team,
I am trying to rewrite https://exapmle.in.com to https://exapmle2.out.net (URL are fake).
I have tried HTTP header rewriting ( without success) and body rewriting 9 the URL was redirecting to the new URL, which is not our case).
We need to keep the traffic to Fortiweb and not redirect the traffic to the end URL.
Bello the config
config waf url-rewrite url-rewrite-rule
edit "ASK-AI-REWRITING"
set host-status enable
set host exapmle.in.com
config header-insert
end
config response-header-insert
end
config header-removal
end
config response-header-removal
end
set request-remove-duplicate-headers disable
config match-condition
edit 1
set reg-exp exapmle2.out.net
set HTTP-protocol https
next
end
next
end
config waf url-rewrite url-rewrite-rule
edit "ASK-AI-REWRITING-2"
set action http-response-header-rewrite
set location_replace $0exapmle.in.com$1
set location-status enable
config header-insert
end
config response-header-insert
end
config header-removal
end
config response-header-removal
end
set response-replace-existing-headers enable
config match-condition
edit 1
set object http-location
set reg-exp (.*)exapmle2.out.net(.*)
next
end
next
end
Attached the URL RULE.
The problem is that the end Application Server is not accepting Requests that done not have exapmle2.out.net in HTTP HEADER( body).
Solved! Go to Solution.
Hello,
We found the solution.
Request Action
1- Request action should match HTTP Host (whole URL- URL1))
2- Replacement URL - select Host - the backend URL (URL2)
Response action
1- Match both HTTP location with syntax (/*)URL2(/*)
and HTTP Host with syntax (.*)URL2(.*)
2- Replacement String: Location - URL1
3- HTTP header Insertion enabled with Replace existing header and syntax $0URL1$1
4- HTTP Header Removal enabled (remove Duplicate Headers)
Also, the backend service should match the frontend service (HTTPs-->HTTPs or HTTP-->HTTP)
The FWB config I provided doesn't do any redirection.
I suspect your back-end server is doing a redirection. I usually see such behavior, for example when back-end server uses an absolute link to itself.
E.g.: instead to redirecting to /login.html, it redirects to server.com/login.html.
Can you check?
Hello,
We found the solution.
Request Action
1- Request action should match HTTP Host (whole URL- URL1))
2- Replacement URL - select Host - the backend URL (URL2)
Response action
1- Match both HTTP location with syntax (/*)URL2(/*)
and HTTP Host with syntax (.*)URL2(.*)
2- Replacement String: Location - URL1
3- HTTP header Insertion enabled with Replace existing header and syntax $0URL1$1
4- HTTP Header Removal enabled (remove Duplicate Headers)
Also, the backend service should match the frontend service (HTTPs-->HTTPs or HTTP-->HTTP)
See Rewriting & redirecting and if needed play with scripting HTTP Commands | FortiWeb 7.6.0 | Fortinet Document Library
User | Count |
---|---|
2534 | |
1350 | |
795 | |
639 | |
455 |
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2025 Fortinet, Inc. All Rights Reserved.