Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    redirect to a web page

    Hi all,

    I have a html login form. Once login is clicked I call a cgi script that checks for the correct password. I then want to redirect to another page or call another cgi script. How do i redirect to another script/webpage using C?
    Last edited by janhar; 09-05-2012 at 05:02 AM. Reason: SOLVED

  2. #2
    Would having it print a javascript window.location work?

    For example:

    if ( $auth == 0 ) {
        printf("<script javascript>");
        printf("alert(\"Auth success!\";);
        printf("window.location = \"mypage.html\";);

  3. #3
    That didn't work for me. This did

    printf("<META HTTP-EQUIV=\"refresh\" content=\"2;URL=mypage.html\">");

    Thank you

  4. $spacer_open
  5. #4
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Seattle, WA, USA
    janhar: that's not quite the right way to do it. Redirection is done by using a special HTTP header, with a 3xx status code (for this case, 302). You can read more here:

    You will need to be able to modify the HTTP header, but this is definitely the most straightforward way to do redirection.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts