php - 如果不存在默认文档,则 IIS web.config 重写
问题描述
如果没有定义的页面(即) ,我有一个web.config
用于 IIS 的部分用于将请求重写到另一个本地文件夹。wwwroot
index.php
所以像这样的网址:www.blah.net/something/index.php
显示正确的页面。但是,www.blah.net/something/
重写到另一个 URL 并忽略该index.php
目录中的。
<configuration>
<system.webServer>
<defaultDocument enabled="true" />
<rewrite>
<rules>
<rule name="RewriteAll" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="_h5ai/public/index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<caching enabled="false" enableKernelCache="true" />
</system.webServer>
</configuration>
解决方案
相当简单,只需添加一个条件来检查文件是否存在。
<conditions>
<add input="{Document_Root}/{REQUEST_URI}/index.php" matchType="IsFile" negate="true" />
</conditions>
此外,在清除本地浏览器缓存后,或在浏览器的隐身窗口中验证结果。
如果问题仍然存在,请随时告诉我。
推荐阅读
- php - 提前退出 Symfony 控制台执行()?
- docker - 如何在只读主机文件系统上运行 docker daemon
- java - Geomesa-utils:如何选择 ResolutionRange
- linux - sed 和 _ 字符的问题
- r - 自定义函数中的 tidyr::uncount() 错误
- spring-boot - @ModelAttribute 对象字段未绑定,并且在控制器中为 null
- electron - Electron 6 - 上下文菜单现在默认使用操作系统的主题(深色或浅色)。如何覆盖这种行为?
- aem - 如何在渲染条件下隐藏项目?
- google-compute-engine - pm2 on Google Compute Engine,多用户开发环境
- java - 如何在java正则表达式中提取整个匹配组