Check PHP if PATH_INFO is enabled on your server?

From PHP, is there a cross-platform firewall way to determine if PATH_INFO is enabled on the server you're running on?

It appears $ _SERVER ['PATH_INFO'] is only populated if there are additional path segments after the script, so you cannot reliably determine if PATH_INFO is included if the request is for /index.php, for example.

+2


source to share


2 answers


I don't think there is a specific way to get the Apache config value like this.

One idea that comes to mind is to make a request using file_get_contents()

to

http://current_site_domain/check.php/test

      

check.php

displays $_SERVER['PATH_INFO']

.

If the result of the query is "test", PATH_INFO works.



Of course, this may fail because URL opening is disabled, because you don't know the local domain, because there is a firewall in there, etc. etc.

Another way that is less error prone is to use iframe

:

<iframe src="/check.php/It%20works!"></iframe>

      

If you can see "it works" inside ifrane, PATH_INFO is working. Perhaps useful for the installation procedure.

+2


source


$ _ SERVER ["PATH_INFO"] should always be available. If it is not, it means that there was no additional information between the file name and the query string.



0


source







All Articles