url forward with query string

Discussion in 'Javascript' started by Adrian, Dec 6, 2005.

  1. Adrian

    Adrian Guest

    Adrian, Dec 6, 2005
    #1
    1. Advertisements

  2. Adrian

    Randy Webb Guest

    Adrian said the following on 12/6/2005 7:15 AM:
    > Hi
    > is it possible (if so how) to do a redirect / url forward with query
    > string


    Yes it is possible.
    How? Add the query string to the URL before redirecting.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Dec 6, 2005
    #2
    1. Advertisements

  3. Use either
    header("Location: http://www.test2.com"._SERVER["REQUEST_URI"]);
    before anything is written to the document(!) as soon as the first
    headers are sent to the browser this won't work.

    Or you can have a redirect meta tag in <head> looking like this:
    <meta http-equiv='Refresh'
    content='0;http://www.test2.com<?=_SERVER["REQUEST_URI"]?>'>
    The digit 0 (zero) before the semicolon in 'content' tell the browser
    to redirect with 0 seconds delay... which you can change if you want to
    display "You are now redirected to test2"

    The choice depends a little on when redirection is supposed to happen.
     
    Dennis Ålund, Dec 6, 2005
    #3
  4. Adrian

    web.dev Guest

    Adrian wrote:
    > Hi
    > is it possible (if so how) to do a redirect / url forward with query
    > string
    >
    > i.e.
    > www.test1.com?pram1=a?pram2=b
    >
    > is forwarded to
    > www.test2.com?pram1=a?pram2=b
    >
    > Thanks


    In addition to the solutions above, you can also do the following in
    javascript:

    location.href = "www.test2.com?pram1=a&pram2=b";
     
    web.dev, Dec 6, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U3Jpbmk=?=
    Replies:
    2
    Views:
    344
    Kevin Spencer
    May 19, 2004
  2. Jon paugh
    Replies:
    1
    Views:
    1,334
  3. Andy G

    Encrypting a query string in URL

    Andy G, May 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    8,574
  4. qazmlp
    Replies:
    1
    Views:
    840
    Jonathan Turkanis
    Feb 15, 2004
  5. Just D.
    Replies:
    0
    Views:
    801
    Just D.
    Aug 11, 2004
  6. roadrunner
    Replies:
    1
    Views:
    418
    Gunnar Hjalmarsson
    Feb 8, 2006
  7. ~greg
    Replies:
    5
    Views:
    354
    ~greg
    Apr 27, 2005
  8. nick
    Replies:
    1
    Views:
    699
    David Mark
    Feb 13, 2011
Loading...