使用web配置从url中删除index.cfm [英] Removing index.cfm from url with web config

查看:370
本文介绍了使用web配置从url中删除index.cfm的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题 -

目前我的网址如下所示: index.cfm / camp / another-test

Currently my urls look like this: index.cfm/camp/another-test

我想让他们看起来像这样: camp / another-test

I would like for them to look like this: camp/another-test

我可以做到这一点很好apache与我的.htaccess,但我需要能够做到在iis7与web.config。这是我到目前为止的重写:

I'm able to do this fine on apache with my .htaccess but I need to be able to do it on iis7 with the web.config. Here's my rewrite so far:

<rewrite>
  <rules>
    <rule name="Remove index.cfm" enabled="true">
      <match url="^(.*)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{SCRIPT_NAME}" negate="true" pattern="^/(assets|files|miscellaneous|robots.txt|favicon.ico|sitemap.xml|index.cfm)($|/.*$)" />
      </conditions>
     <action type="Rewrite" url="/index.cfm/{R:1}" />
    </rule>
  </rules>
</rewrite>

感谢您的帮助!

推荐答案

我相信CFWheels需要你通过rewrite.cfm而不是index.cfm来路由重写请求。

I believe CFWheels requires that you route rewrite requests through rewrite.cfm not index.cfm.

href =http://stackoverflow.com/questions/6312509/different-rewrite-mode-for-cfwheels-website-root>对此问题

See the comment by Chris Peters on this question

如果您调整:

<rewrite>
  <rules>
    <rule name="Remove index.cfm" enabled="true">
      <match url="^(.*)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{SCRIPT_NAME}" negate="true" pattern="^/(assets|files|miscellaneous|robots.txt|favicon.ico|sitemap.xml|index.cfm)($|/.*$)" />
      </conditions>
      <action type="Rewrite" url="/index.cfm/{R:1}" />
    </rule>
  </rules>
</rewrite>

到:

<rewrite>
  <rules>
    <rule name="ColdFusion on Wheels URL Rewriting" enabled="true">
      <match url="^(.*)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll">
        <add input="{SCRIPT_NAME}" matchType="Pattern" ignoreCase="true" negate="true" pattern="^/(flex2gateway|jrunscripts|cfide|CFFileServlet|cfformgateway|railo-context|files|images|javascripts|miscellaneous|stylesheets|robots.txt|favicon.ico|sitemap.xml|rewrite.cfm)($|/.*$)" />
      </conditions>
      <action type="Rewrite" url="/rewrite.cfm/{R:1}" />
    </rule>
  </rules>
</rewrite>

它应该可以解决你的问题,只要你有:

it should solve your problem, provided you have:

<cfset set(URLRewriting = "On")>

在/config/settings.cfm

within /config/settings.cfm

这篇关于使用web配置从url中删除index.cfm的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆