Relative 302 redirects

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

  1. athanasius

    athanasius New 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?

    Thanks.
  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 New 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->code(302);
    $response->header('Status' => $response->status_line());
    $response->header('Location' => '/images/logo.gif');
    print $response->headers()->as_string() . "\n" . $response->content();

    Thanks.
  4. mistwang

    mistwang LiteSpeed Staff

    That's strange,
    If LSWS receives some thing like
    Code:
    Status: 302\n
    Location: /images/logo.gif\n
    \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 http://you.host/your/url", or other tool.
  5. athanasius

    athanasius New Member

    mistwang,

    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