Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在Apache中只允许一个文件_Php_.htaccess_Apache - Fatal编程技术网

Php 如何在Apache中只允许一个文件

Php 如何在Apache中只允许一个文件,php,.htaccess,apache,Php,.htaccess,Apache,我有一个引导文件,它是index.php,我只允许其他人调用这个页面 我已经想出了下面的代码,我收到了一个内部500错误。我喜欢显示日志文件,但我不能,因为我正在共享主机上运行,但我知道这是CGI模式 我把代码放在.htaccess中,收到错误并把它放在php.ini中,结果不起作用 <File /index.php> Allow from all Require None Satisfy Any </File> 通融 不需要 满足任何 我做错了什么?我

我有一个引导文件,它是
index.php
,我只允许其他人调用这个页面

我已经想出了下面的代码,我收到了一个内部500错误。我喜欢显示日志文件,但我不能,因为我正在共享主机上运行,但我知道这是CGI模式

我把代码放在
.htaccess
中,收到错误并把它放在
php.ini
中,结果不起作用

<File /index.php>
  Allow from all
  Require None
  Satisfy Any
</File>

通融
不需要
满足任何

我做错了什么?

我所做的只是将所有请求重定向到
index.php
文件,并让索引文件处理任何错误的请求,因为它已经处理了所有友好的URL请求和所有内容。这样,在索引文件中就不需要额外的代码了。它将正常运行,看到“somefile.php”和他们试图打开的页面,并确定这不是一个要打开的有效页面,然后像任何其他无效路径一样出错,至少我的设置方式是这样的

RewriteEngine On
RewriteBase /
RewriteRule .* index.php [L]
如果你没有像我一样为它们使用子域,你将不得不排除任何图像或CSS文件夹,或者你也可以用索引文件处理它们

排除图像和css文件夹的示例:

RewriteRule !^(images|css)/.* index.php [L]
或者,如果您不想这样做,您可以将所有不允许的文件发送到
-

RewriteRule !^(index\.php|images/.*|css/.*) - [L]

所以基本上所有的东西都会被index.php文件处理?@BookOfZeus:是的,只有index.php会处理东西,其他文件只包含扩展名.php(不是.inc)。你的.htaccess文件或vhost文件中有其他规则吗?我使用同样的技术。apache配置中是否有
File
指令?在这个世界上没有一个人。