Hello everyone,
I am encountering a difficulty.
I’m trying to set up the following redirection in HTTPS :
from :
https://redirect.econohm.com/?param1=value1
to :
https://www.econohm.com/#?param1=value1
I can’t find a way to do it without using Apache and the .htaccess file.
Thank you in advance for your valuable help.
JBG.
On the client side you can use the js history object’s replaceState to change the URL – that is assuming you don’t need to change the loaded content. You could also reassign the URL with the location object’s assign method on the client side.
hello2
June 21, 2024, 1:19pm
3
Just to help you along as per what @duncan_richards12 advised.
Your https://redirect.econohm.com/?param1=value1
request endpoint could be as follows to open a client form:
@anvil.server.route("/")
def redirect(**params):
anvil.server.FormResponse('Form', **properties)
Then on the client-side in Form add under __init__
from anvil.js.window import location
location.replace(f"https://www.econohm.com/#?param1={properties['param1']}")
I finally managed to handle this problem with the help of @anvil.server.route ()
Yep, it’s here. Respond to any path within your app’s domain with @anvil.server.route:
@anvil.server.route("/hello")
def hello(**p):
return {"hello":"world"}
$ curl https://my-interesting-app.anvil.app/hello
{"hello":"world"}
But wait - there’s more!
What if you don’t just want to serve a machine-readable response? What if you want to serve a human-accessible UI on a particular URL instead?
Just return a FormResponse object:
@anvil.server.route("/my-page")
def my_page(**p):
re…
Thank you very much for your assistance, which guided me towards the most suitable solution for my needs
Hi @jean-bruno.getenay ,
I’m glad you’ve solved your problem! Now that it’s solved, could you perhaps describe what you did and paste a little sample code into the thread? That way, the next person who has this question can find this thread and see the answer!
2 Likes