downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Case 3: setting doc_root or user_dir> <Case 1: only public files served
[edit] Last updated: Fri, 26 Apr 2013

view this page in

Case 2: using cgi.force_redirect

The configuration directive cgi.force_redirect prevents anyone from calling PHP directly with a URL like http://my.host/cgi-bin/php/secretdir/script.php. Instead, PHP will only parse in this mode if it has gone through a web server redirect rule. PHP older than 4.2.0 used --enable-force-cgi-redirect compile time option for this.

Usually the redirection in the Apache configuration is done with the following directives:

Action php-script /cgi-bin/php
AddHandler php-script .php

This option has only been tested with the Apache web server, and relies on Apache to set the non-standard CGI environment variable REDIRECT_STATUS on redirected requests. If your web server does not support any way of telling if the request is direct or redirected, you cannot use this option and you must use one of the other ways of running the CGI version documented here.



add a note add a note User Contributed Notes Case 2: using cgi.force_redirect - [4 notes]
up
1
harvey dot eneman at oracle dot com
3 years ago
It appears that as of 5.3.0, --enable-force-cgi-redirect is not a valid configure option.  A quick review of the 5.3.0 code indicates that it the logic previously enabled by specifying the --enable-force-cgi-redirect configure option is being built into php by default.
up
0
mega-squall at caramail dot com
5 years ago
Contrary to what was said, you can use arbitrary names for your MIME Type ...
However there's a restriction as it must be a valid MIME Type.
For instance, this is working perfectly :

AddHandler application/x-httpd-php4 .php4
AddHandler application/x-httpd-php5 .php5 .php
AddHandler application/x-httpd-php6 .php6
up
0
celtic at sairyx dot org
6 years ago
Note that force-redirect doesn't work with IIS at all; it'll tell you to go away, as IIS doesn't supply the right variables to PHP.

php.ini tells you to turn it off, so make sure you do.
up
-1
gelgin at internut dot com
6 years ago
solaris 9 php4.4.0
i have found you can't use arbitrary names ie.

AddType application/x-httpd-php .php

works

#AddHandler php4-script .php

won't do must be

AddHandler application/x-httpd-php

 
show source | credits | stats | sitemap | contact | advertising | mirror sites