大家好!
假如我有一个web应用,目录为my_app,放到apache的应用程序根目录中,我想限制浏览器访问my_app/templates目录,该目录存放了一些html模板,如登录注册框之类的。能进行限制吗,该如何做?

解决方案 »

  1.   

    <Directory "E:/wamp/www/my_app/templates">
        Options FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from none
    </Directory>试试 
      

  2.   

    也可以在目录下面放个空的index.html文件
      

  3.   

    这个内容是在apache的配置文件httpd.conf里面吗?路径是否加引号,也试过了,服务器也重启了,还是不行。
    将内容写到templates目录下面的.htaccess文件也不行,这个就没重启服务器。额,我菜鸟啊。
      

  4.   

    写到 httpd.conf 里面就行。路径要写对。之后重启apache再测试。
      

  5.   

    <Directory "E:/wamp/www/my_app/templates">
      Options None
      AllowOverride None
      Order deny,allow
      Deny from all
    </Directory>
      

  6.   

    httpd.conf中:
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order deny,allow
        Allow from all
    </Directory>templates目录下建立文件.htaccess,如下内容:
    Options None
    AllowOverride None 
    Order deny,allow
    Deny from all这样子可以了。尝试访问templates目录下面的文件,会得到如下错误:
    Internal Server ErrorThe server encountered an internal error or misconfiguration and was unable to complete your request.Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.More information about this error may be available in the server error log.