2010-02-01 72 views
1

什么是最好的方式发送到您的网站的所有流量404页?我目前正在网站上工作,并希望所有请求都只有404。我尝试过使用htaccess文件,但是并没有像这样工作得太成功。另外,我希望访问特定文件夹的流量仍然可以通过。发送所有流量404错误

回答

5

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

但是,在行之间读取它听起来像您想要在根文件夹中查看该网站,并阻止任何其他人执行相同操作。在我看来,你想要做的是看看Apache手册对身份验证部分,授权 http://httpd.apache.org/docs/2.0/howto/auth.html

喜欢的东西在你的Apache配置的位置或目录段以下,或在.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