ForceType/PHP without .php extension

Discussion in 'Install/Configuration' started by lux, Apr 19, 2005.

  1. lux

    lux New Member

    I'm trying to get the following htaccess settings to work:

    Code:
    <Files index>
       ForceType application/x-httpd-php
    </Files>
    The documentation says the ForceType directive works, but the <Files> block doesn't seem to. Is there a way of accomplishing the above in Litespeed? I did make sure all the htaccess options were selected (except 'None'). What's probably happening is I need an AddHandler or something like that, but I haven't gotten any variation (the above is from the original Apache config) to work.

    Thanks in advance,

    Lux
  2. mistwang

    mistwang LiteSpeed Staff

    support for <Files> block will be added in 2.1 release, there is no good alternative right now, so there is no way to make it work in .htaccess. However, it is doable with lsws matching context, from web admin interface, create a matching static context like "URI=> exp:(.*)/index", "location=>$DOC_ROOT$1/index", set force MIME Type to "application/x-httpd-php". it should work exactly like your htaccess settings.
  3. lux

    lux New Member

    Thanks for the suggestion. I'm not able to get this to work however. Here are the steps I took:

    1. Go to "Server Configuration" then select the appropriate Virtual Host.
    2. Click the "Context" tab.
    3. Click "Add".
    4. Select "Static" from the list of types.
    5. Enter "exp:(.*)/index" into the URI field.
    6. Enter "$DOC_ROOT$1/index" into the Location field.
    7. Set "Accessible" to "Yes".
    8. Set "Force MIME Type" to "application/x-httpd-php".
    9. Click "Save".

    I left all other fields as their defaults (empty in most cases). This seems to have no effect, and the file still loads as a binary file which the browser prompts me to save.

    Let me know if I missed a step or something.

    Thanks again,

    Lux
  4. lux

    lux New Member

    Reload

    I forgot it in the list of steps above, but I did reload the virtual host as well.

    Cheers,

    Lux
  5. mistwang

    mistwang LiteSpeed Staff

    You probably need to clear your browser's cache. :)
  6. lux

    lux New Member

    I'm afraid not. I tried that to make sure, and I also tried accessing it from the command line via:

    bash$ telnet localhost 8088
    ...
    HEAD /index HTTP/1.0

    And the output was an application/octet-stream file there too.
  7. mistwang

    mistwang LiteSpeed Staff

    Is there a script handler for ".php" defined? otherwise, "application/x-httpd-php" is undefined.
  8. lux

    lux New Member

    It's pretty much a stock Lite Speed installation. I found the following:

    Suffix: php
    Handler Type: Fast CGI
    Handler Name: "[Server Level]: phpFcgi"
  9. mistwang

    mistwang LiteSpeed Staff

    We tried it again, it works.

    Please set "Location" to "$DOC_ROOT/$1/index", then restart the web server. "Reload" virtual host may not work properly.
    Make sure to disable override, or remove those .htaccess files.
  10. lux

    lux New Member

    Awesome! It works perfectly now. Our software, a PHP-based content management system, works perfectly with Lite Speed now.

    Thanks,

    Lux
  11. aambults

    aambults New Member

    Same problem

    Hi !

    I have a same problem when tried to migrate from Apache 2.0.54 to LIGHTSPEED 2.2.

    There are .htaccess (in DOCROOT) file whitch force apache+php to use file portal as php file :

    ...

    <Files portal>
    ForceType application/x-httpd-php
    </Files>

    ...

    Then I add context in vhost context :
    ...
    <context>
    <type>NULL</type>
    <uri>exp:(.*)/portal</uri>
    <location>$DOC_ROOT/$1/portal</location>
    <allowBrowse>1</allowBrowse>
    <forceType>application/x-httpd-php</forceType>
    <accessControl>
    </accessControl>
    <addDefaultCharset>off</addDefaultCharset>
    <rewrite>
    </rewrite>
    </context>
    ...

    But it force lightspeed to use portal as php file, but without parameeters. I need to use portal with parameeters for example :

    /portal/news/73/articles/81077

    In fact there was no directory news or 73 or articles - those are parameeters whitch portal should understood.

    What should I change in context definitions ?

    Andris
  12. mistwang

    mistwang LiteSpeed Staff

    You can try:
    Code:
     
    <uri>exp: (.*)/portal/(.*)</uri>
    
    Only drawback is that PATH_INFO environment variable will no longer be set. If you code depends on _SERVER['PATH_INFO'] you can consider use

    Code:
     
    <location>$DOC_ROOT/$1/portal?path_info=$2</location>
     
    
    _REQUEST['path_info'] is what _SERVER['PATH_INFO'] was.

Share This Page