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 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?