dongmi5177 2010-02-01 01:46
浏览 44
已采纳

发送所有流量404错误

What is the best way to send all traffic to your site a 404 page? I'm currently working on the site and would like it to just 404 for all requests. I've tried playing around with htaccess files but haven't been too successful in getting one working like this. Additionally, I would like traffic to a particular folder to still get through.

  • 写回答

1条回答 默认 最新

  • duan2891 2010-02-01 01:54
    关注

    As your question is stated the easiest way would be to move all your content into that folder.

    However, reading between the lines it sounds like you want to view the site in the root folder, and block anyone else from doing the same. It seems to me what you want to do is look at the Apache manual's section on Authentication and Authorization http://httpd.apache.org/docs/2.0/howto/auth.html

    Something like the following in a Location or Directory section of your Apache config, or in a .htaccess file should work. You can put the page you want to show your users in a special location

          #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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100