Relative 302 redirects

Discussion in 'Install/Configuration' started by athanasius, Feb 23, 2006.

  1. athanasius

    athanasius Member

    We are currently moving from apache to lsws and I cannot seem to get a 302 redirect to work when using a relative url.

    This works on apache but not on lsws:

    Location: /images/logo.gif
    Content-Type: text/html; charset=ISO-8859-1
    Status: 302 Found

    Absolute urls work on both. Am I doing something wrong here or does lsws not support relative urls for redirects?

  2. mistwang

    mistwang LiteSpeed Staff

    Is the redirect from a script or with server configuration.

    You should create a redirect context if you want to do it with server configuration. An example:

    URI /redirectme
    External Redirect Yes
    Status Code 302 Found
    Destination URI /index.html
  3. athanasius

    athanasius Member

    The redirect is from a perl script which works on apache. The following would be a sample of that script which is running in the context of a FastCGI App, not normal cgi:

    my $response = HTTP::Response->new();
    $response->header('Status' => $response->status_line());
    $response->header('Location' => '/images/logo.gif');
    print $response->headers()->as_string() . "\n" . $response->content();

  4. mistwang

    mistwang LiteSpeed Staff

    That's strange,
    If LSWS receives some thing like
    Status: 302\n
    Location: /images/logo.gif\n
    LSWS will do external redirect. If status is absent, LSWS will do internal redirect. Just like Apache. maybe the status line is below Location or absent.
    Can you post the reply header, with "lynx -mime_header", or other tool.
  5. athanasius

    athanasius Member


    Figured it out. Seems as though this line in my script was causing the problem:

    $response->header('Status' => $response->status_line());

    It does not affect relative redirects on apache, but it does on lsws. It is actually not needed so after removing it, relative redirects work fine on lsws.

    Thank You.

Share This Page