Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass URL parameters when redirecting to another URL?

I'm using this html code to redirect to another URL when the page (www.dasinfobuch.de/links/Wizz) is invoked:

<head>
  <meta http-equiv="refresh" content="0; URL=http://52.28.104.181:8080/Wizard/Wizz">
</head>

However, when I use a URL parameter such as

www.dasinfobuch.de/links/Wizz?template=test

the parameter is not passed on to the redirected page. Is there a way to accomplish this (preferably in plain HTML)? (I'm new to Web programming.)

like image 881
lukas.coenig Avatar asked Jul 24 '15 06:07

lukas.coenig


People also ask

How redirect to another page and pass parameter in URL?

To redirect to another page in JavaScript, you can use window. location. href property, window. location will also work and if you want you can use window.

Can you redirect URLs with parameters?

You can use URL Redirect to forward your visitors to a specific page at the destination URL and pass values via query strings to the destination.

How do I pass a URL with multiple parameters into a URL?

To add a parameter to the URL, add a /#/? to the end, followed by the parameter name, an equal sign (=), and the value of the parameter. You can add multiple parameters by including an ampersand (&) between each one.

How do I route a URL to another URL?

Click the URL Redirects tab. In the upper right, click Add URL redirect. In the right panel, select the Standard or Flexible redirect type. A standard redirect is used to redirect one URL to another.


1 Answers

This is not possible using only a meta element that mimics the non-standard Refresh HTTP header field. Of course there are other ways.

If you’ve got something like a preprocessor, you can pass on the request to the HTML, like so:

<meta http-equiv="refresh"
      content="0; URL=http://52.28.104.181:8080/Wizard/Wizz?template=<%
           out.print(request.getParameter("template")) %>">

Another (client-side) way is to redirect using JavaScript:

document.location.href = 'http://52.28.104.181:8080/Wizard/Wizz' + document.location.search;

Note that this will carry over the entire query string, not just the template parameter and its argument. If that’s a problem, it’s easy to get only the desired string from location.search.

like image 54
dakab Avatar answered Sep 22 '22 12:09

dakab