We are trying to replace part of the URI in a script but we have not been able to, we have managed to rewrite it but the parameters that the URI brings us are lost.
This is the example script we are trying to make.
Url example : https://host.com/test_replace/index.html
Url final : https://host.com/services/command/index.html
when HTTP_REQUEST {
host=HTTP:header_get_value("Host")
path=HTTP:path_get()
debug("**** host is %s path is %s\n", host, path)
if path:find("/test_replace/") then
HTTP:path_set("/services/command/")
end
Nominating a forum post submits a request to create a new Knowledge Article based on the forum post topic. Please ensure your nomination includes a solution within the reply.
Try the steps from this example script:
when HTTP_REQUEST {
# Get the URI from the HTTP request.
uri = HTTP:path_get()
# Split the URI into the path and query parameters.
path, query_params = uri:split("?")
# Replace the path with the desired path.
path = path:replace("/test_replace/", "/services/command/")
# Join the path and query parameters back into a URI.
new_uri = path:join("?", query_params)
# Set the HTTP path to the new URI.
HTTP:path_set(new_uri)
}
This script will replace the path /test_replace/ with the path /services/command/ in the URI, but it will keep the query parameters intact.
Select Forum Responses to become Knowledge Articles!
Select the “Nominate to Knowledge Base” button to recommend a forum post to become a knowledge article.
User | Count |
---|---|
1634 | |
1063 | |
751 | |
443 | |
210 |
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 2024 Fortinet, Inc. All Rights Reserved.