Coldfusion IIS重写 [英] Coldfusion IIS Rewrite

查看:188
本文介绍了Coldfusion IIS重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试映射这样的网址:

I'm trying to map a URL like this:

www.domain.com/some-page.cfm?coid=1

更加用户友好:

www.domain.com/some-page/company-name

www.domain.com/company-name

我一遍又一遍地尝试使用URL Rewrite在IIS中,不能为我的生活让它工作。

I've tried over and over using URL Rewrite in IIS and can't for the life of me get it to work.

任何帮助将不胜感激!

推荐答案

我认为你可能真的想做相反的事情......使用IIS将 /abc.htm 请求映射到 /?id = abc ,对吗? (对于您要求的规则,我建议使用ColdFusion编写它。)

I think you may actually want to do the opposite... use IIS to map /abc.htm requests to /?id=abc, right? (For the rule you are requesting, I recommend writing that using ColdFusion.)

这是我们使用的IIS规则,以便不在我们的博客中公开.cfm网址。 URL中/ blog /之后的任何URL参数都可以作为 URL.WebPath 用于ColdFusion。保留其他URL参数。如果您修改此项,我建议您匹配网址格式(例如blog /或/ detail-),以便只重写指定的网址。

Here's an IIS rule that we use in order to not expose ".cfm" in our blog URLs. Anything URL parameters after "/blog/" in the URL is available to ColdFusion as URL.WebPath. Additional URL parameters are retained. If you modify this, I recommend matching a URL patterns (like "blog/" or "/detail-") so that only specified URLs are rewritten.

<rewrite>
  <rules>
    <rule name="CFMBlog" patternSyntax="ECMAScript" stopProcessing="true">
      <match url="blog/(.*.htm)$" ignoreCase="true" />
      <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
        <add input="{SCRIPT_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{PATH_INFO}" pattern="^.*(blog/index.cfm/).*$" negate="true" />
      </conditions>
      <action type="Rewrite" url="/blog/index.cfm?WebPath={R:0}" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>

在ColdFusion方面,您需要分析URL并确保其格式正确。您不希望两个版本的URL都因为担心SEO重复而响应(除非您设置URL规范化)。我是我的经验,最好将301永久重定向提供给URL的小写,破折号分隔的.htm版本。

On the ColdFusion-side, you'll want to analyze the URL and ensure it's in the proper format. You don't want to have both versions of the URLs responding for fear of SEO duplication (unless you set up URL canonicalization). I'm my experience, it's best to serve a 301 Permanent Redirect to a lowercased, dash-separated ".htm" version of the URL.

在您的CFM页面中,你需要添加一些逻辑来检查 .htm 是否在 path_info URL .COID 存在于原始请求中,而 URL.webpath 则不存在。根据您的具体情况,您可以执行301以重定向到URL的HTM版本,以便搜索引擎和用户知道新网址。

In your CFM pages, you'll need to add some logic to check whether .htm is in path_info, URL.COID exists in the original request and URL.webpath does not. Depending on your situation, you could perform a 301 to redirect to the HTM version of the URL so that both search engines & users are aware of the new URL.

这篇关于Coldfusion IIS重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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