在 IIS 下使用一个 web.config 规则,出现一个很怪的问题(偶尔 500)。

2017-01-21 22:37:51 +08:00
 lslqtz
多个程序都有这种现象,可排除程序问题。。,或许是服务端配置的问题?
curl 结果,似乎只有静态文件(js/css)才会 500 :
C:\Users\lslqtz>curl -I http://abc.com/content/themes/default/bootstrap/js/bootstrap.min.js
HTTP/1.1 500 Internal Server Error
Content-Length: 27822
Content-Type: application/x-javascript
Last-Modified: Sat, 14 May 2016 15:49:00 GMT
Accept-Ranges: bytes
ETag: "03ebd21f8add11:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Sat, 21 Jan 2017 14:36:23 GMT

C:\Users\lslqtz>curl -I http://abc.com/content/themes/default/bootstrap/js/bootstrap.min.js
HTTP/1.1 200 OK
Content-Length: 27822
Content-Type: application/x-javascript
Last-Modified: Sat, 14 May 2016 15:49:00 GMT
Accept-Ranges: bytes
ETag: "03ebd21f8add11:0"
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Sat, 21 Jan 2017 14:36:25 GMT

C:\Users\lslqtz>

附上 IIS 规则:
<rule name="1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTP_HOST}" pattern="^abc.com$" />
<add input="{URL}" pattern="^/abc/" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="abc/{R:1}" appendQueryString="true" />
</rule>
是在 IIS 下直接用.htaccess 转过来的,原规则:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^abc.com$ [NC]
RewriteCond %{REQUEST_URI} !^/abc/
RewriteRule ^(.*)$ abc/$1 [L,QSA]
2615 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/336128

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX