Setting up External App Context

Discussion in 'Install/Configuration' started by artagesw, Jun 9, 2007.

  1. artagesw

    artagesw New Member

    Is there a way to direct only a specific file to an external app like lsphp? For example, I want to redirect /index (with no .php extension), but no other files in that directory, to php. So far, the only way I have been able to direct files to external applications is by mapping file extensions. I'm looking for something like Apache's "ForceType" directive.
  2. mistwang

    mistwang LiteSpeed Staff

    Yeah, just create a static context with uri "/index" then set the "Force MIME Type" to "application/x-httpd-php".
  3. artagesw

    artagesw New Member

    I appreciate the quick response. Thanks!
  4. artagesw

    artagesw New Member

    Hmmm. This isn't working for me. I set up a static context, url = "/index.html" location = "index.html", "Force MIME Type" = "application/x-httpd-php".

    But the index.html page is getting served as text.
  5. mistwang

    mistwang LiteSpeed Staff

    Is there a script handler defined for ".php"? make sure to clear your browser cache.
  6. artagesw

    artagesw New Member

    Yes. Accesing /index.php works fine (strangely, even though there is no index.php file).

    In the help for "Force MIME Type" it says all files will be served as *static files.* Is this perhaps the problem?
  7. mistwang

    mistwang LiteSpeed Staff

    OK, we will check the "Force MIME Type" configuration, let's try a different approach now, remove "Force MIME Type" configuration, set "Add MIME Type" with "application/x-httpd-php .html".
  8. artagesw

    artagesw New Member

    OK, I assume you meant "application/x-httpd-php html" (without the dot), right?

    That doesn't work either.

    http://www.mydomain.com/ is still served as text.

    but...

    http://www.mydomain.com/index.html is served as a 404 page.

    I wonder if there is some interaction between this context and the rewrite rules in the virtual host?

    The virtual host's rewrite rules look like this:

    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]
    RewriteRule ^(.*) index.html
  9. artagesw

    artagesw New Member

    I just discovered that if I change the context URI to "/" (instead of "/index.html") it works. But I assume that this will cause all .html files to be processed by php. I would like to set it up to process only the index.html file as php and all other html files as static html.
  10. mistwang

    mistwang LiteSpeed Staff

    Does index.html exist? I don't understand why it is served as 404, maybe you should turn on debug logging.

    rewrite rules at vhost level does not have a rewrite base, you need to fix the last rewrite rule by giving the full URI.

    You can force the MIME type by using rewrite rule as well.
    That's another option.
  11. artagesw

    artagesw New Member

    like this?

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.+) - [PT,L]
    RewriteRule ^(.*) /index.html
  12. mistwang

    mistwang LiteSpeed Staff

    Yes, something like that.
  13. artagesw

    artagesw New Member

    Well I have it mostly working. However, it only works if I set the context URI to "/" (instead of "/index.html"). This causes all .html files to be processed by php. I would like to set it up to process only the index.html file as php and all other html files as static html. Are you sure this is possible? LiteSpeed does not seem to like a context URL that is a file. It seems only to support directory URLs.
  14. mistwang

    mistwang LiteSpeed Staff

    Please try a matching context "exp:^/(index.html)?$", make sure the sequence order of this context is "1".
  15. artagesw

    artagesw New Member

    That did not work either. It is the only context, so it is sequence order 1.

    Here are the context settings:

    URI exp:^/(index.html)?$
    Location Not Set
    Accessible Yes
    Notes Not Set
    Enable Expires Not Set
    Expires Default Not Set
    Expires By Type Not Set
    Extra Headers Not Set
    MIME Type application/x-httpd-php html
    Force MIME Type Not Set
    Default MIME Type Not Set
    Index Files Not Set
    Auto Index Not Set
    Allow Override Not Set
    Realm Not Set
    Authentication Name Not Set
    Required Not Set
    Access Allowed Not Set
    Access Denied Not Set
    Authorizer Not Set
    Add Default Charset Off
    Customized Default Charset Not Set
    Enable Rewrite Not Set
    Rewrite Inherit Not Set
    Rewrite Base Not Set
    Rewrite Rules Not Set
    Enable IP GeoLocation Not Set
    Apache Style configurations Not Set
  16. mistwang

    mistwang LiteSpeed Staff

    location should be set to "$DOC_ROOT/index.html", and use "Froce MIME Type" instead of "MIME Type"
  17. artagesw

    artagesw New Member

    Success! That did the trick. Thanks so much for your help.

Share This Page