save_alt   Windows_IIS_rewrite_amd64_zh-CN.zip

save_alt Windows_IIS_rewrite_amd64_en-US.zip

 


URL Rewrite Module 2.1

解决404错误,路由重定向

IIS URL Rewrite 2.1 使 Web 管理员能够创建强大的规则,以实现用户更易记住、搜索引擎更易找到的 URL。通过使用集成到 IIS 管理器中的规则模板、重写映射、.NET 提供程序和其他功能,Web 管理员可以轻松设置规则,基于 HTTP 标头、HTTP 响应或请求标头、IIS 服务器变量甚至复杂的编程规则来定义 URL 重写行为。此外,Web 管理员还可以根据重写规则中表达的逻辑执行重定向、发送自定义响应或停止 HTTP 请求。


在前端根目录下(如C:\inetpub\wwwroot)创建 web.config 文件,写入如下规则代码:

save_alt web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.webServer>
    <rewrite>
      <rules>
        <rule name="Vue Router History Mode" stopProcessing="true">
          <match url="^.*$" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <!-- 排除API请求 -->
            <add input="{REQUEST_URI}" pattern="^/api/" negate="true" />
            <!-- 排除静态资源 -->
            <add input="{REQUEST_URI}" pattern="\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>
  </system.webServer>
</configuration>


linux + apache 组合 配置文件名:.htaccess

save_alt htaccess.zip

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  
  # 直接返回已存在的文件和目录
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]
  
  # 排除 API 请求
  RewriteCond %{REQUEST_URI} !^/api/
  
  # 排除常见的静态资源扩展名
  RewriteCond %{REQUEST_URI} !\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|json|xml)$ [NC]
  
  # 将其他请求重写到 index.html
  RewriteRule ^ /index.html [L]
</IfModule>

环境监测

PM2.5/10、温湿度、有害气体等实时监测