一个aspx的网站有一个web.config的文件,里面有一个伪静态的规则 :
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<configSections>
<section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
</configSections>
<RewriterConfig>
<Rules>
<RewriterRule>
<LookFor>~/index\.html</LookFor>
<SendTo>~/index.aspx</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/LineList-(\d+)\.html</LookFor>
<SendTo>~/LineList.aspx?classId=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/News-(\d+)\.html</LookFor>
<SendTo>~/News.aspx?classid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/cplist-(\d+)\.html</LookFor>
<SendTo>~/cplist.aspx?classid=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/News-(\d+)/(\d{0,999999})\.html</LookFor>
<SendTo><![CDATA[~/News.aspx?classId=$1&Page=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/cgal-(\d+)/(\d{0,999999})\.html</LookFor>
<SendTo><![CDATA[~/cgal.aspx?classId=$1&Page=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/cplist1-(\d+)/(\d{0,999999})\.html</LookFor>
<SendTo><![CDATA[~/cplist1.aspx?classId=$1&Page=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/newms-(\d+)/(\d{0,999999})\.html</LookFor>
<SendTo><![CDATA[~/newms.aspx?classId=$1&Page=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/shengnei-(\d+)/(\d{0,999999})\.html</LookFor>
<SendTo><![CDATA[~/shengnei.aspx?classId=$1&Page=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/xjxm-(\d+)/(\d{0,999999})\.html</LookFor>
<SendTo><![CDATA[~/xjxm.aspx?classId=$1&Page=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/NewsCon-(\d+)-(\d+)\.html</LookFor>
<SendTo><![CDATA[~/NewsCon.aspx?ClassId=$1&Id=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/detail-(\d+)-(\d+)\.html</LookFor>
<SendTo><![CDATA[~/detail.aspx?ClassId=$1&Id=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/cdetail-(\d+)-(\d+)\.html</LookFor>
<SendTo><![CDATA[~/cdetail.aspx?ClassId=$1&Id=$2]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/zsjm-(\d+)-(\d+)\.html</LookFor>
<SendTo><![CDATA[~/zsjm.aspx?Id=117&option=6]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/lxwm-(\d+)-(\d+)\.html</LookFor>
<SendTo><![CDATA[~/lxwm.aspx?Id=81&option=1]]></SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/jiameng-(\d+)\.html</LookFor>
<SendTo>~/jiameng.aspx?Id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/LinesYD-(\d+)\.html</LookFor>
<SendTo>~/LinesYD.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/Contact-(\d+)\.html</LookFor>
<SendTo>~/Contact.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/About-(\d+)\.html</LookFor>
<SendTo>~/About.aspx?id=$1</SendTo>
</RewriterRule>
<RewriterRule>
<LookFor>~/kong\.html</LookFor>
<SendTo>~/kong.aspx</SendTo>
</RewriterRule>
</Rules>
</RewriterConfig>
<!-- appSettings网站信息配置-->
<appSettings>
<add key="Configpath" value="~/XmlConfig/webset.config" />
<!--<add key="DbPath" value="~/App_Data/DtCms.aspx"/>-->
<add key="DbPath" value="~/App_Data/DtCms.mdb" />
</appSettings>
<!-- 数据库连接字符串-->
<connectionStrings>
<add name="ConnectionString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" />
</connectionStrings>
<system.web>
<httpModules>
<add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
</httpModules>
<httpHandlers>
<add verb="*" path="*.html" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="*" path="*.xml" type="URLRewriter.RewriterFactoryHandler, URLRewriter" />
<add verb="POST,GET" path="ajaxpro/*.ashx" type="AjaxPro.AjaxHandlerFactory, AjaxPro.2" />
</httpHandlers>
<!--
设置 compilation debug="true" 可将调试符号插入
已编译的页面中。但由于这会
影响性能,因此只在开发过程中将此值
设置为 true。
-->
<customErrors mode="Off" />
<compilation debug="true">
<buildProviders>
<add extension=".html" type="System.Web.Compilation.PageBuildProvider" />
<add extension=".xml" type="System.Web.Compilation.PageBuildProvider" />
</buildProviders>
</compilation>
<!--
通过 <authentication> 节可以配置 ASP.NET 用来
识别进入用户的
安全身份验证模式。
-->
<authentication mode="Windows" />
<!--
如果在执行请求的过程中出现未处理的错误,
则通过 <customErrors> 节可以配置相应的处理步骤。具体说来,
开发人员通过该节可以配置
要显示的 html 错误页
以代替错误堆栈跟踪。
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpRuntime maxRequestLength="20480" executionTimeout="600" />
</system.web>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear />
<clear />
<add value="index.aspx" />
<add value="Default.htm" />
<add value="Default.asp" />
<add value="index.htm" />
<add value="index.html" />
<add value="iisstart.htm" />
<add value="default.aspx" />
</files>
</defaultDocument>
<urlCompression doDynamicCompression="true" />
<httpErrors errorMode="Detailed" />
<handlers>
<add name="html" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="File" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
</handlers>
</system.webServer>
</configuration>
我换了一个asp虚拟主机,首页可以打开,但是点击上面的链接打开都提示404,好像伪静态没起作用,这个可能是什么问题?
ASP.NET 是一个用于开发动态 Web 应用的服务器端脚本语言。在 ASP.NET 中,可以通过配置 URL 重写规则来实现伪静态。
例如,您可以在 ASP.NET 项目的 Web.config 文件中添加以下代码来启用 URL 重写:
上面的代码中,我们定义了一条 URL 重写规则,将所有非文件非目录的 URL 重写为 *.aspx 格式的 URL。
更多关于 ASP.NET 中的伪静态设置的信息,您可以查阅相关的文档和教程。