SetHandler directive - Apache with php installed as cgi module

Discussion in 'Site & Server Administration' started by paulocon, Feb 16, 2009.

  1. #1
    Hi all,

    Any help here would be greatly appreciated.

    I recently developed a website and user the setHandler directive in .htaccess to implement search-engine friendly URL's.

    e.g.

    www.mydomain.com/category/football

    instead of

    www.mydomain.com/category.php?catId=3

    I have a php page called category (no extension) that parses the URL to find the category (in this case football).

    My .htaccess looks like

    <Files "category">
    setHandler application/x-httpd-php
    </Files>

    <Files "guarantee">
    setHandler application/x-httpd-php
    </Files>

    <Files "contact_us">
    setHandler application/x-httpd-php
    </Files>

    <Files "contact">
    setHandler application/x-httpd-php
    </Files>

    This worked a treat on the server on which I deveoped the site but when I moved it to my client's hosting servers, it didn't.

    Atfer a lot of correspondence (don't you just love help desks!), I finally got the following answer:

    Thank you for contacting our technical support team.
    Commands you are using are used on the servers where php is installed as Apache module to specify mime type that should be used to identify files. Please note that php on your server is installed as cgi module and such directives do not work. Please use correct directives for php installed as cgi. Should you have any further questions or problems, please feel free to contact us any time, we are available 24/7.

    Anyone know what the correct directive are or how I can implement this. Any help would be really appreciated on this one.
    Reply With Quote
     
    paulocon, Feb 16, 2009 IP
  2. JPC-NickO

    JPC-NickO Guest

    Messages:
    69
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi Paul,

    If they are using php running as a cgi module you need to use the ForceType directive instead of SetHandler.

    If that still doesn't work problem is probably that "application/x-httpd-php" is incorrect for the server as this can be anything. Try using "application/x-httpd-php5".

    If that does not work and your using cPanel ask them to provide the output of:
    # cat /etc/httpd/conf/php5.htaccess

    which should look something like this:
    # Use PHP5 as default
    AddHandler application/x-httpd-php5 .php
     
    JPC-NickO, Feb 17, 2009 IP