当前位置:论坛首页 > Windows面板 > Windows面板教程

Asp/Aspx程序如何设置伪静态/重定向等功能

发表在 Windows面板2020-6-30 10:10 [复制链接] 11 13632

说明:
    Asp/Aspx程序一般都有默认的一套配置文件,所以面板暂不支持自动配置伪静态功能,需要自己手动配置。
    web.config路径在网站(站点)根目录下

如何手动配置?

分为两种情况,情况如下:

1、当Asp程序根目录不存在web.config文件,或者配置文件内容为如下代码时:

可以直接将面板生成的代码复制到伪静态,保存即可
  1. <?xml version="1.0" ?>
  2. <configuration>
  3.     <location allowOverride="false" inheritInChildApplications="false" path=".">
  4.         <system.webServer>
  5.             <rewrite>
  6.                 <rules configSource="web_config\rewrite.config"></rules>
  7.             </rewrite>
  8.             <defaultDocument configSource="web_config\default.config"></defaultDocument>
  9.             <httpErrors configSource="web_config\httpErrors.config"></httpErrors>
  10.             <handlers configSource="web_config\php.config"></handlers>
  11.         </system.webServer>
  12.     </location>
  13. </configuration>
复制代码
      

2、当Aspx程序和Asp程序根目录自带了web.config文件时:
     如原配置为以下格式:
      1.png

3、(重要)当Asp网站不存在原有配置文件时,将网站目录下的web.config文件内容替换成以下代码即可
  1. <?xml version="1.0" ?>
  2. <configuration>
  3.         <location path="." allowOverride="false" inheritInChildApplications="false">
  4.           <system.webServer>
  5.                <rewrite>
  6.                      <rules>                        
  7.                          <rule name="http_toHttps" stopProcessing="true">
  8.                              <match url="(.*)"/>
  9.                              <conditions>
  10.                                   <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
  11.                              </conditions>
  12.                              <action type="Redirect" redirectType="Permanent" url="https://{HTTP_HOST}/{R:1}"/>
  13.                              </rule>
  14.                      </rules>
  15.                 </rewrite>
  16.           </system.webServer>
  17.         </location>
  18. </configuration>
复制代码



     手动修改后的代码:

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







使用道具 举报 只看该作者 回复
发表于 2021-3-31 00:56:39 | 显示全部楼层
经过测试,把文件内的代码替换为以下代码是可以的
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3.     <system.webServer>
  4.         <rewrite>
  5.             <rules>
  6.                 <rule name="HTTP to HTTPS redirect" stopProcessing="true">
  7.                     <match url="(.*)" ></match>
  8.                     <conditions>
  9.                         <add input="{HTTPS}" pattern="^OFF$" ></add>
  10.                     </conditions>
  11.                     <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" ></action>
  12.                 </rule>
  13.             </rules>
  14.         </rewrite>
  15.     </system.webServer>
  16. </configuration>
复制代码
使用道具 举报 回复 支持 3 反对 0
发表于 2020-6-30 11:13:48 | 显示全部楼层
学习下
使用道具 举报 回复
发表于 2020-6-30 16:06:11 | 显示全部楼层
这个感觉确实比较麻烦,我前两天也遇到案例,一个客户说安装环境既要支持asp,也要php,头疼,用win系统的织梦开启伪静态也麻烦的很。。
使用道具 举报 回复 支持 反对
发表于 2020-7-1 11:19:30 | 显示全部楼层
多谢楼主分享!
使用道具 举报 回复 支持 反对
发表于 2020-11-8 10:22:58 | 显示全部楼层
做了301跳转www后再301跳转https,浏览器均打不来网站,提示跳转太多
使用道具 举报 回复 支持 反对
发表于 2020-11-11 13:23:55 | 显示全部楼层
加在下级了 无法跳转
使用道具 举报 回复 支持 反对
发表于 2020-11-20 21:09:38 | 显示全部楼层
<system .webserver>
  <rewrite>
   <rules>
     <rule name="http_toHttps" stopProcessing="true">
        <match url="(.*)"/>
        <conditions>
                <add ignoreCase="true" input="{HTTPS}" pattern="off"/>
        </conditions>
        <action redirectType="Permanent" type="Redirect" url="https://{HTTP_HOST}/{R:1}"/>
</rule>
  </rules>
  </rewrite>
</system .webserver>
使用道具 举报 回复 支持 反对
发表于 2020-11-20 21:10:18 | 显示全部楼层
我配置了好像不得行,不能强制开启
使用道具 举报 回复 支持 反对
发表于 2020-11-21 20:38:01 | 显示全部楼层
不行呀。这咋搞
使用道具 举报 回复 支持 反对
发表于 2021-9-18 13:17:30 | 显示全部楼层
Warren 发表于 2021-3-31 00:56
经过测试,把文件内的代码替换为以下代码是可以的

IIS管理器内该网站的 SSL设置,“要求SSL”一定不要勾选,会造成 http 403 或者 500 错误,无法跳转 https。
使用道具 举报 回复 支持 反对
发表于 2023-2-1 15:38:49 | 显示全部楼层
iis 7.5的绑定SSL 网站都打不开了,不知道为什么?
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

企业版年付运维跟进群

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急问题处理

论坛响应时间:10分钟

问题处理方式:1对1处理(优先)

工作时间:白班:9:00 - 18:00

工作时间:晚班:18:00 - 24:00

立即付费处理
快速回复 返回顶部 返回列表