URL重写问题,cfm到.net

时间:2019-06-25 22:32:05

标签: .net redirect url-rewriting coldfusion

我要重定向

#!/usr/bin/env bash

shopt -s extglob # setup extended globbing so it can match group multipe times

# Find all files or directories names that:
# either starts with spaces,
# or ends with spaces,
# or contains any of the \ " : < > ; | * ? prohibited characters
find . \
  -depth \
  \( -type f -or -type d \) \
  -regextype posix-extended \
  -regex '.*/([[:space:]].*|.*[[:space:]]|.*[\\":<>;|*?].*)' \
  -print0 \
  | while IFS= read -r -d '' filename; do

    # Isolates the file name from its directory path
    base="$(basename -- "${filename}")"

    # ExtGlob strips-out all instances of prohibited characters class using //
    # [\\\":<>;|*?]
    base="${base//[\\\":<>;|*?]/}"

    # ExtGlob strips-out leading spaces
    # *([[:space:]]):
    # * 0 or any times the following (group)
    # [[:space:]] any space character
    base="${base/*([[:space:]])/}"

    # ExtGlob strips-out trailing spaces using %%
    base="${base%%*([[:space:]])}"

    # Compose a new file name from the new base
    newFilename="$(dirname -- "${filename}")/${base}"

    # Prevent the new file name to collide with existing files
    # by adding a versionned suffix
    suffix=''
    count=1
    while [[ -e "${newFilename}${suffix}" ]]; do
      suffix=".$((count++))"
    done
    newFilename="${newFilename}${suffix}"

    printf \
      "original: '%s'\\nnew     : '%s'\\n\\n" \
      "${filename}" \
      "${newFilename}"
    mv -- "${filename}" "${newFilename}"

  done

echo 'Done.'

somewebsite.tld/oldpage.cfm?Query=505050

我已经完成了以下

在web.config中,我添加了一个处理程序来处理.cfm请求

somewebsite.tld/New?ref=505050

我添加了以下电子写入规则,但是它不起作用。

<system.webServer>
 <handlers>
  <add name="ColdFusion" path="*.cfm" verb="*" type="System.Web.StaticFileHandler" resourceType="Unspecified" preCondition="integratedMode" />
 </handlers>
</system.webServer>

我能够使用urlmapping至少使用以下规则从/ View中读取请求。

<rewrite>
 <rules>
  <rule name="Redirect oldpage.cfm" stopProcessing="true">
   <match url="oldpage\\.cfm(\\?(\\w+)=(\\d+))" /> <action type="Redirect" url="New?ref={R:3}" appendQueryString="false" redirectType="Permanent" />
  </rule>
 </rules>
</rewrite>

但是,这仍然无法获取查询字符串。

0 个答案:

没有答案