2017-03-08 26 views
2

我正在将一个大型数据库驱动的网站从coldfusion.cfm移动到.net aspx。我现在已经完成了很多工作,但是我需要在所有的Coldfusion页面上重新定向到新的aspx页面,所以谷歌和我们不想失去搜索引擎定位。所以我打算为此使用URL重写,但我无法使它工作,大部分时间我只是拿回404s。使用IIS的IIS重写URL将所有Cold Fusion CFM页面移动到ASP aspx页面

基本上,我的新aspx页面都是相同的文件名,只是.cfm被替换为.aspx,一些页面可以有一个很长的查询字符串后,有些不是。

例子:

http://www.example.com/test.cfm需要被重新映射到http://www.example.com/test.aspx

http://www.example.com/test2.cfm?a=1&b=2&c=3需要被重新映射到http://www.example.com/test2.aspx?a=1&b=2&c=3

本身有上百页,有些页面有查询字符串超过8个变量的网站,所以我只想尝试在URL重写中进行直接映射。我不能每页都做一个规则,因为这将需要很长时间!

我现在的尝试是:

<rule name="redirect all requests" stopProcessing="true"> 
<match url="^(.*)$" ignoreCase="true" /> 
<conditions logicalGrouping="MatchAll"> 
<add input="{URL}" pattern="^http://www.example.com/(.*).cfm(.*)$" /> 
</conditions> 
<action type="Redirect" url="http://www.example.com/{C:1}.aspx" appendQueryString="true" logRewrittenUrl="true" /> 
</rule> 

这只是做了404对我来说。很明显,cfm页面不存在,aspx页面现在可以做到。我现在仍然在服务器上安装冷聚变,并且不希望在谷歌更新自身之前卸载它(这是一个问题,所以我总是可以回去)。

任何帮助将不胜感激。

感谢

大卫

+0

不是IIS 404页面命名文件,它试图加载?!? –

回答

0

是这样的......

<rule name="CFM301ASP" stopProcessing="true"> 
    <match url="^(.*)$" /> 
    <conditions> 
     <add input="{REQUEST_FILENAME}" pattern="^.*\.cfm$" negate="false" ignoreCase="true" /> 
     <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true"/> 
    </conditions> 
    <action type="Redirect" url="/yourfile.aspx" appendQueryString="true" redirectType="Permanent" /> 
</rule> 

上不存在CFMS(ISFILE = FALSE)这只适用。它会将会导致404的CFM重定向到您的ASP文件并附加URL变量。

0

文档似乎涵盖了这一切。

从文档上HTTP Redirect

<configuration> <system.webServer> <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found"> <add wildcard="*.php" destination="/default.htm" /> </httpRedirect> </system.webServer> </configuration>

这使我相信,你应该能够从一个文件extenstion URL映射到另一个。

Creating Rewrite Rules for the URL Rewrite Module

<rewrite> <rules> <rule name="Rewrite to article.aspx"> <match url="^article/([0-9]+)/([_0-9a-z-]+)" /> <action type="Rewrite" url="article.aspx?id={R:1}&amp;title={R:2}" /> </rule> </rules> </rewrite>

试图通过这些文档阅读,你应该能够找到正确的语法,这将让你刚从*.cfm转移到*.aspx,沿着相同的查询字符串传递,或进行根据需要翻译。

+0

这个例子不重定向,它是一个重写。它并不保留所有的url变量。 – Jules