Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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 向所有通信发送404错误_Php_Apache_.htaccess - Fatal编程技术网

Php 向所有通信发送404错误

Php 向所有通信发送404错误,php,apache,.htaccess,Php,Apache,.htaccess,将所有流量发送到404页面的最佳方式是什么?我目前在该网站工作,并希望它只是404的所有请求。我尝试过使用htaccess文件,但没有成功地使一个文件像这样工作。此外,我希望特定文件夹的流量仍然可以通过。正如您的问题所述,最简单的方法是将您的所有内容移动到该文件夹中 但是,从字里行间看,您似乎想查看根文件夹中的站点,并阻止其他任何人这样做。在我看来,您想要做的是查看Apache手册中关于身份验证和授权的部分 在Apache配置的Location或Directory部分中,或者在.htacces

将所有流量发送到404页面的最佳方式是什么?我目前在该网站工作,并希望它只是404的所有请求。我尝试过使用htaccess文件,但没有成功地使一个文件像这样工作。此外,我希望特定文件夹的流量仍然可以通过。

正如您的问题所述,最简单的方法是将您的所有内容移动到该文件夹中

但是,从字里行间看,您似乎想查看根文件夹中的站点,并阻止其他任何人这样做。在我看来,您想要做的是查看Apache手册中关于身份验证和授权的部分

在Apache配置的Location或Directory部分中,或者在.htaccess文件中,应该可以使用以下类似的方法。您可以将要向用户显示的页面放在特殊位置

      #The page you want to show denied users.
      ErrorDocument 403 /path/to/403.html
      #The page you want to show when pages aren't found (404)
      ErrorDocument 404 /path/to/404.html

      #For Password Protection
      #Use the htpasswd utility to generate .htpasswd
      AuthType Basic
      AuthName "My Secret Stuff"
      AuthUserFile /path/to/my/passwords/.htpasswd
      Require valid-user

      #For IP protection
      Order allow,deny
      Allow from 1.2.3.4 #Your IP Here

      #If you want to use a combination of password and IP protection
      #This directive works if they have a valid IP OR a valid user/pass
      Satisfy any

正如您的问题所述,最简单的方法是将您的所有内容移动到该文件夹中

但是,从字里行间看,您似乎想查看根文件夹中的站点,并阻止其他任何人这样做。在我看来,您想要做的是查看Apache手册中关于身份验证和授权的部分

在Apache配置的Location或Directory部分中,或者在.htaccess文件中,应该可以使用以下类似的方法。您可以将要向用户显示的页面放在特殊位置

      #The page you want to show denied users.
      ErrorDocument 403 /path/to/403.html
      #The page you want to show when pages aren't found (404)
      ErrorDocument 404 /path/to/404.html

      #For Password Protection
      #Use the htpasswd utility to generate .htpasswd
      AuthType Basic
      AuthName "My Secret Stuff"
      AuthUserFile /path/to/my/passwords/.htpasswd
      Require valid-user

      #For IP protection
      Order allow,deny
      Allow from 1.2.3.4 #Your IP Here

      #If you want to use a combination of password and IP protection
      #This directive works if they have a valid IP OR a valid user/pass
      Satisfy any