Apache Rewrite to LiteSpeed Contexts

Discussion in 'Install/Configuration' started by mabonyi, Nov 4, 2006.

  1. mabonyi

    mabonyi New Member

    I am converting an old site which relies heavily on 'pretty URLs' and Apache Rewrite rules. I understand that LiteSpeed can have Static or CGI contexts which use regular expressions. At the VHost level, I already have a lsapi PHP looking at php, html and php3 extensions, but the following Static rule just shows the source file:

    Code:
      URI: exp:^/help/sections/([0-9]+)\.html
      Root: $DOC_ROOT/help/showsection.php?section=$1
      Accessible: Yes
    
    I tried using a CGI context as well, but I received this error:

    Code:
    lscgid: execve(): Permission denied
    
    Obviously it is trying to execute it, but it shouldn't be using lscgid in the first place -- I want it to use lsphp.

    Any suggestions?
  2. mistwang

    mistwang LiteSpeed Staff

    Maybe browser cached the result when you testing different configuration. It should work if URL "/help/showsection.php?section=..." works. Please try clearing your browser cache.
  3. mabonyi

    mabonyi New Member

    I cleared out the browser cache and tried both Static and CGI contexts. Same result. The php file is executable, overrides are allowed but not for this context, and the VHost has scripts enabled, restrained and symbol links allowed.

    As a side note, I don't use the per-directory .htaccess file to create rewrites which achieve this same goal in Apache, because in LiteSpeed, the rewrite becomes a redirect -- the URL changes. But I'm not bothered by that; I would rather use the LiteSpeed method of contexts.

    I am using LSWS 2.2.4 Ent.
  4. mistwang

    mistwang LiteSpeed Staff

    Do not use CGI contexts. Static is fine.
    You need to make sure URL "/help/showsection.php?section=..." work properly first.
    LiteSpeed's rewrite behave the same as Apache's, will not redirect (change URL in user's brower) unless '[R]' flag is used, PHP_SELF variable may change though, as Apache is not consistent on this.
  5. mabonyi

    mabonyi New Member

    Ok. Using a Static Context with only these settings:

    Code:
    URI: exp:^/help/sections/([1-9][0-9]*)\.html$
    Root: $DOC_ROOT/help/showsection.php?section=$1
    Accessible: Yes
    
    I only ever get the source of showsection.php. When I enter the URL manually, it works and I can see the lsphp instance run in top on the server. Would there be any reason why the VHost script handler doesn't catch the static context?
  6. mabonyi

    mabonyi New Member

    Here's what the Debug set to HIGH gives:

    Code:
    
    2006-11-04 16:40:22.687 [DEBUG] [*:80] New connection from xxx.xxx.xxx.xxx:34571.
    2006-11-04 16:40:22.687 [DEBUG] [*:80] 1 connections accepted!
    2006-11-04 16:40:22.687 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] HttpIOLink::handleEvents() events=1!
    2006-11-04 16:40:22.687 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] HttpConnection::onReadEx(), state: 0!
    2006-11-04 16:40:22.687 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] readToHeaderBuf(). 
    2006-11-04 16:40:22.687 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] Read from client: 314
    2006-11-04 16:40:22.687 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] read 314 bytes to header buffer
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] processHeader() return 0, header state: 3. 
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0] readToHeaderBuf() return 0. 
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] New request: 
            Method=[GET], URI=[/help/sections/10.html],
            QueryString=[]
            Content Length=0
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] processContextPath() return 0
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] readyCacheData() return 0
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] Written to client: 1603
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] m_pHandler->onWrite() return 0
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] HttpConnection::flush()!
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] HttpConnection::nextRequest()!
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] Non-KeepAlive, CLOSING!
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] processNewReq() return 0. 
    2006-11-04 16:40:22.688 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] Shutting down out-bound socket ...
    2006-11-04 16:40:23.638 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] HttpIOLink::handleEvents() events=17!
    2006-11-04 16:40:23.638 [DEBUG] [xxx.xxx.xxx.xxx:34571-0#www.virtualhost.com] Close socket ...
    
  7. mistwang

    mistwang LiteSpeed Staff

    Maybe another non-matching context with higher priority get into the way. Please change the sequence number of this context to a lower number to give it higher priority. Or only define this context under this vhost.

Share This Page