doufang3001 2015-10-31 10:38
浏览 61
已采纳

在“拒绝所有人”之后,原始域名调用不再可访问,只允许“index.php”

I've tried to avoid access files on my webspace in general. Only the index.php should be allowed. I don't want to reach this goal without using mod_rewrite. My actual code is the following:

Order Deny,Allow
Deny from all
Allow from 127.0.0.1

<Files /index.php>
    Order Allow,Deny
    Allow from all
</Files>

It works when I'm calling my website like www.example.com/index.php, but it doesn't work when I leave the index.php from the URL like www.example.com/

I thought the Apache webserver would know to use the index.php when no segment to the URL is added.

Can you help me out here to understand it and tell .htaccess to allow a raw domain-call?

  • 写回答

1条回答 默认 最新

  • doushenyu2537 2015-10-31 11:03
    关注

    i think you better have to use some regular expressions to solve this issue

    using <FilesMatch> tag instead of <Files> tag

    <FilesMatch "^(index\.php)?$">
        Order Allow,Deny
        Allow from all
    </FilesMatch>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥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#的问题,如何解决?