使用PHP检查的AllowOverride价值?价值、PHP、AllowOverride

2023-09-02 00:27:27 作者:月似当时

反正是有使用PHP来检查的AllowOverride 的价值也看看的.htaccess 会产生什么影响?

Is there anyway to use PHP to check the value of AllowOverride too see if .htaccess will have any effect?

推荐答案

我不知道一个干净的,直接的方式来做到这一点。

I am not aware of a clean, direct way to do this.

如果您有HTTP访问要检查这个文件夹,你可以写东西到.htaccess文件将触发某种输出。

If you have http access to the folder you want to check this for, you could write something into the .htaccess file that will trigger a certain kind of output.

例如,你可以设置一个标题(这有一个额外的依赖 mod_headers中,虽然):

For example, you could set a header (this has an added dependency on mod_headers, though):

<FilesMatch ".(php)$">
<IfModule mod_headers.c>
Header set htaccess_works "yes"
</IfModule>
</FilesMatch>

然后做从PHP的请求,并检查响应头,如使用 卷曲 CURLOPT_HEADER 。如果它们所包含的 htaccess_works 头,它的工作原理。

then make a request from PHP, and check the response headers, e.g. using curl's CURLOPT_HEADER. If they contain the htaccess_works header, it works.

另一种方法,是可怕的,但保证独立于特定的Apache模块的工作就是编程写乱码到的.htaccess 文件,然后做出卷曲要求像上面,并以检查 500 状态code。如果它抛出一个500,.htaccess文件了跨preTED。但正如所说,这是可怕的 - 如果可能的话,请用头方法,而不是

Another method that is terrible but guaranteed to work independently from specific Apache modules is to programmatically write gibberish into the .htaccess file, then to make a curl request like above, and to check for a 500 status code. If it throws a 500, the .htaccess file got interpreted. But as said, this is terrible - if possible, go with the headers method instead.