[英]Rewrite rule “URL as parameter” in IIS web.config (returns error 500)
I mange "URL as parameter" with Apache .htaccess using flag [B]
我使用标志
[B]
使用Apache .htaccess来管理“ URL作为参数”
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{THE_REQUEST} \s/+(\S+)
RewriteRule (.*) index.php?i=%1 [B,L]
Unfortunately can't figure out how to do the same in IIS web.config 不幸的是无法弄清楚如何在IIS web.config中执行相同的操作
<configuration>
<system.webServer>
<defaultDocument enabled="true">
<files>
<clear/>
<add value="index.php"/>
</files>
</defaultDocument>
<modules runAllManagedModulesForAllRequests="true"/>
<rewrite>
<rules>
<rule name="rule" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?i={R:1}" appendQueryString="true" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Lets say web.config is under http://localhost/dir/web.config ... 可以说web.config在http://localhost/dir/web.config下 ...
Results: Opening http://localhost/dir/ and http://localhost/dir/example executes index.php correctly, but accessing http://localhost/dir/i/http://example.org returns error 500 The page cannot be displayed because an internal server error has occurred.
结果:开放的http://本地主机/目录/和HTTP://本地主机/目录/示例执行的index.php正确,但访问HTTP://本地主机/目录/ I / HTTP://example.org返回错误500
The page cannot be displayed because an internal server error has occurred.
Expected: http://localhost/dir/i/http://example.org must execute index.php with $_GET['i']
value dir/i/http://example.org
预期: http:// localhost / dir / i / http://example.org必须使用
$_GET['i']
值dir/i/http://example.org
http://example.org执行index.php
It seems IIS doesn't allow to use in URL :/
... Any workaround/fix for it? 看来IIS不允许在URL中使用
:/
...是否有任何解决方法/修复程序?
Tools like http://www.htaccesstowebconfig.com doesn't convert .htaccess correctly, your help/advice would be very appreciated. 像http://www.htaccesstowebconfig.com这样的工具无法正确转换.htaccess,非常感谢您的帮助/建议。
The only way I find the way to respond URLs containing :/
and returning multiple slash value/query ://...
(example URL http://localhost/dir/i/http://example.org ) was by using UNENCODED_URL
; 我找到响应包含
:/
URL并返回多个斜杠值/查询://...
(示例URL http:// localhost / dir / i / http://example.org )的唯一方法是UNENCODED_URL
; fallowing answer: 休闲的答案:
<rule name="Index" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
</conditions>
<action type="Rewrite" url="index.php?i={UNENCODED_URL}" appendQueryString="true" />
</rule>
Notice, it will return value begining /
like /dir/i/http://example.org
. 注意,它将返回以
/
/dir/i/http://example.org
值,例如/dir/i/http://example.org
。
Any hacking around to allow special symbols, like 任何骇客行为,以允许使用特殊符号,例如
<system.web>
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" relaxedUrlToFileSystemMapping="true" AllowRestrictedChars="1" UrlSegmentMaxLength="2048" />
<pages validateRequest="false" />
</system.web>
<security>
<requestFiltering allowDoubleEscaping="false" />
</security>
didn't give any benefit in order to solve the issue (no need for it). 没有为解决该问题提供任何好处(不需要)。
Update: It works fine on local Windows 10 machine, but still returns error 500 on Azure servers. 更新:在本地Windows 10计算机上工作正常,但在Azure服务器上仍返回错误500。 No idea why.
不知道为什么。
ModuleName IIS Web Core
Notification BEGIN_REQUEST
HttpStatus 500
HttpReason Internal Server Error
HttpSubStatus 19
ErrorCode The specified path is invalid.
(0x800700a1)
ConfigExceptionInfo \\?\D:\home\site\wwwroot\i\http:\web.config ( 0) :Cannot read configuration file
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.