【问题标题】:Directory Specific url rewriting in IIS ColdFusionIIS ColdFusion 中的目录特定 url 重写
【发布时间】:2018-06-06 10:13:26
【问题描述】:

我有网站 http://example.com/school/student.cfm?id=100

另外,我还有另一个链接http://example.com/collage/student.cfm?id=200

我想写一个 URL 重写规则,它总是重写 http://example.com/school/student.cfm?id=100http://example.com/school/student/100

http://example.com/collage/student.cfm?id=200http://example.com/collage/student/200

我已经写了这样的规则,但总是使用 1 个目录,但我希望这适用于所有目录。

<rule name="Redirect to school with ONE parameter" stopProcessing="true">
    <match url="^.*/([^/]+)/?$" />
        <conditions>
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
        </conditions>
    <action type="Rewrite" url="school/student.cfm?id_Name={R:1}" />
</rule> 

【问题讨论】:

    标签: mod-rewrite iis coldfusion


    【解决方案1】:

    有很多方法可以解决这个问题。解决方案的范围从 - 仅重写学校和拼贴画 - 到重写以学生结尾的任何路径 - 到使用重写所有内容的通用模式。

    让您了解如何使用 IIS 的正则表达式:

    <match url="^(collage|school)/student/([0-9]+)/?$" />
    <action type="Rewrite" url="{R:1}/student.cfm?id={R:2}" />
    
    <match url="^([^/]+)/student/([0-9]+)/?$" />
    <action type="Rewrite" url="{R:1}/student.cfm?id={R:2}" />
    
    <match url="^([^/]+)/([^/]+)/([0-9]+)/?$" />
    <action type="Rewrite" url="{R:1}/{R:2}.cfm?id={R:3}" />
    

    【讨论】:

    • 伟大的作品就像一个魅力。它解决了我的问题。非常感谢:)
    猜你喜欢
    • 2015-10-09
    • 1970-01-01
    • 1970-01-01
    • 2017-01-30
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 2019-09-09
    • 1970-01-01
    相关资源
    最近更新 更多