阿里云代理商-阿里云服务器-阿里云数据库-重庆典名科技

宝塔Windows面板配置Asp/Aspx伪静态/重定向

发布时间: 2022-02-23 14:36:35文章作者: 网站编辑阅读量: 252
  宝塔Windows面板面板暂不支持自动配置Asp/Aspx伪静态功能,Asp/Aspx程序一般都有默认的一套配置文件,需要自己手动配置,请将以下代码添加到网站目录下的【web.config】文件中,添加完毕后重启IIS生效。
  web.config路径在网站(站点)根目录下分两种情况配置?

  1、当Asp程序根目录不存在web.config文件,或者配置文件内容为如下代码时:可以直接将面板生成的代码复制到伪静态/web_config/rewrite.config,保存即可。

?xml version="1.0" ?>
<configuration>
    <location allowOverride="false" inheritInChildApplications="false" path=".">
        <system.webServer>
            <rewrite>
                <rules configSource="web_config\rewrite.config"></rules>
            </rewrite>
            <defaultDocument configSource="web_config\default.config"></defaultDocument>
            <httpErrors configSource="web_config\httpErrors.config"></httpErrors>
            <handlers configSource="web_config\php.config"></handlers>
        </system.webServer>
    </location>
</configuration>
  示例:test01.wnana.com 301跳转到 test01.wnana.com
  ……/web_config/rewrite.config

<?xml version="1.0" ?>
<rules>
<rule name="1645586406920_redirect" stopProcessing="true">
	<match url="(.*)"/>
	<conditions logicalGrouping="MatchAny">
		<add input="{HTTP_HOST}" pattern="^test01.wnana.com"/>
	</conditions>
	<action type="Redirect" redirectType="Permanent" url="http://test02.wnana.com"/>
</rule>
</rules>
  重启/重载IIS后重定向生效


  重启/重载IIS后重定向生效
  2、当Aspx程序和Asp程序根目录自带了web.config文件时:

  如原配置为以下格式:


  手动修改后的代码:
  注意1:如果【图1】中存在<system.webServer>/<rewrite>/<rules>,则直接加入在下级节点

  注意2:如果【图1】中不存在<system.webServer>/<rewrite>/<rules>,则需要手动添加,下图为手动添加【<system.webServer>/<rewrite>/<rules>】


联系客服免费领取更多阿里云产品新购、续费升级折扣,叠加官网活动折上折更优惠