虛擬主機根目錄下的web.config配置常見問題

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <configSections>
    <section name="RewriterConfig" type="URLRewriter.Config.RewriterConfigSerializerSectionHandler, URLRewriter" />
  </configSections>
  <appSettings />
  <RewriterConfig>

 

    <Rules>

	
      <!--<RewriterRule>
        <LookFor>/(.*)/(.*)/</LookFor>
        <SendTo>/city/type/index.aspx?c=$1&t=$2</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/(.*)/(.*)/p(.[0-9]*).aspx</LookFor>
        <SendTo>/city/type/index.aspx?c=$1&t=$2&page=$3</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/(.*)/</LookFor>
        <SendTo>/city/index.aspx?c=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/com/(.[0-9]*).aspx</LookFor>
        <SendTo>/com/index.aspx?u=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/(.*)/(.*)/(.[0-9]*).aspx</LookFor>
        <SendTo>/city/type/view.aspx?c=$1&t=$2&id=$3</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/(.*)/(.*)/search-(.*).aspx</LookFor>
        <SendTo>/city/type/search.aspx?c=$1&t=$2&s=$3</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/post/(.[0-9]*)-(.[0-9]*).aspx</LookFor>
        <SendTo>/post/fb.aspx?t=$1&c=$2</SendTo>
      </RewriterRule>-->
      <RewriterRule>
        <LookFor>/index.html</LookFor>
        <SendTo>index.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/about/(.[0-9]*).html</LookFor>
        <SendTo>/about/show.aspx?id=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/news/(.[0-9]*)/(.[0-9]*).html</LookFor>
        <SendTo>/news/list.aspx?t=$1&page=$2</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/news/view/(.[0-9]*).html</LookFor>
        <SendTo>/news/show.aspx?id=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/proc/(.[0-9]*)/(.[0-9]*).html</LookFor>
        <SendTo>/proc/list.aspx?o=$1&page=$2</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/proc/view/(.[0-9]*).html</LookFor>
        <SendTo>/proc/show.aspx?id=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/ask/(.[0-9]*).html</LookFor>
        <SendTo>/ask/list.aspx?t=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/ask/show/(.[0-9]*).html</LookFor>
        <SendTo>/ask/show.aspx?id=$1</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/ask/add.html</LookFor>
        <SendTo>/ask/add.aspx</SendTo>
      </RewriterRule>
      <!--<RewriterRule>
        <LookFor>/search/list.html</LookFor>
        <SendTo>/search/list.aspx</SendTo>
      </RewriterRule>
      <RewriterRule>
        <LookFor>/search/list.html</LookFor>
        <SendTo>/search/list.aspx?k=$1&page=$2</SendTo>
      </RewriterRule>-->
    </Rules>
  </RewriterConfig>
  <connectionStrings>
    <add name="DBString" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|!@@#.mdb" />
  </connectionStrings>
  <system.web>
    <httpModules>
      <add type="URLRewriter.ModuleRewriter, URLRewriter" name="ModuleRewriter" />
    </httpModules>
    <httpHandlers>
      <add verb="*" path="*.aspx" type="URLRewriter.RewriterFactoryHandler,URLRewriter" />
    </httpHandlers>
    <!-- 防止添加的數據 包括HTML等非GB2312數據時出現錯誤 -->
    <pages validateRequest="false" enableEventValidation="false" viewStateEncryptionMode="Never" />
    <compilation debug="true">
    </compilation>
    <authentication mode="Windows" />
    <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
      <error statusCode="403" redirect="NoAccess.htm" />
      <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>
  </system.web>
  <system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="index.html" />
        <add value="index.htm" />
        <add value="index.asp" />
        <add value="default.aspx" />
        <add value="default.htm" />
        <add value="default.asp" />
        <add value="index.aspx" />
      </files>
    </defaultDocument>
        <handlers>
            <add name="html" path="*.html" verb="*" modules="IsapiModule" scriptProcessor="C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll" resourceType="Unspecified" preCondition="classicMode,runtimeVersionv2.0,bitness32" />
        </handlers>
        <httpErrors errorMode="DetailedLocalOnly" />



<!-- 吧不帶china.cn重定向到www.china.cn -->
 <rewrite>
      <rules>
        <rule name="Redirect to WWW" stopProcessing="true">
          <match url=".*" />
          <conditions>
            <add input="{HTTP_HOST}" pattern="^china.cn$" />
          </conditions>
          <action type="Redirect" url="http://www.china.cn/{R:0}" redirectType="Permanent" />
        </rule>
<rule name="Redirect to root" patternSyntax="Wildcard" stopProcessing="true"> 
<match url="index.html" /> 
<action type="Redirect" url="/" appendQueryString="false" redirectType="Permanent" /> 
</rule>  
      </rules>
</rewrite>





  </system.webServer>
</configuration>



  


---

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章