【发布时间】:2017-04-12 16:11:34
【问题描述】:
我正在将一个站点从 IIS 7 移动到 Apache 2.4 并且有以下 web.config 重写规则我在转换为 .htaccess 时遇到了问题。该规则本质上允许通过使用 .cfm 扩展名重写所有没有扩展名的文件(例如 www.mydomain/bag 在服务器上重写为 www.mydomain.com/bag.cfm。在 web 中的工作规则.config 如下所示
<rule name="Rewrite all non extension requests to .cfm" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}.cfm" matchType="IsFile" ignoreCase="false" />
</conditions>
<action type="Rewrite" url="{R:1}.cfm" />
</rule>
我已经尝试了所有可以在这里找到的类似帖子,但不幸的是,它们都不适合我。如果这很重要,我会在 CentOS 7 (Apache 2.4) 上运行 Lucee 5.0。任何指导将不胜感激。
【问题讨论】:
-
您应该能够自定义此答案以使用 .cfm 而不是 .html:stackoverflow.com/questions/5745490/…
-
谢谢,是的,我以前试过没有运气。我认为这可能与在 Apache 之后通过 tomcat 代理的“.cfm”文件有关。当我使用您建议的链接时,我似乎接近了,因为当我打开日志记录时,我看到以下内容。
strip per-dir prefix: /home/domain/public_html/bag.cfm -> bag.cfm applying pattern '^(.*)$' to uri 'bag.cfm' pass through /home/domain/public_html/bag.cfm Negotiation: discovered file(s) matching request: /home/domain/public_html/bag (None could be negotiated). -
到达 htaccess 时,从非 .cfm 重写为 .cfm 为时已晚。
-
那么重写需要在哪里?
标签: apache .htaccess mod-rewrite coldfusion lucee