dtcmadj31951 2018-08-03 13:02
浏览 100
已采纳

如何列出目录内容

How to access directory files when we don't have index file.

I used this htaccess code but it worked when I mention file but I want to show directory file without insert index file.

Please check my htaccess code and tell me where i am wrong thanks

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ check.html?url=$1 [QSA,L]
  • 写回答

1条回答 默认 最新

  • duanmi8349 2018-08-03 13:14
    关注

    You can use the Options configuration option. The documentations presents Options by saying

    Configures what features are available in a particular directory

    You can use many options, the one you are looking for is Indexes. To add this option you need the instruction Options +Indexes.

    In an .htaccess file you can use it simply by putting this.

    # Allows Apache to list the directory content
    Options +Indexes
    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-l
    RewriteRule ^(.*)$ check.html?url=$1 [QSA,L]
    

    In a vhost file it could be like this.

    <Directory /var/www/html/mysite>
      Options +Indexes
    </Directory>
    

    I suggest to use this in your vhost file though.

    As said in comment it's recommanded to configure a site in a vhost file. If you can (if your host allows you), use the vhost instead of the .htaccess file. If you can set all your configuration in your vhost and avoid using .htaccess, you can use AllowOverride None to forbid the .htaccess usage then.

    See the wiki and the documentation.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法