将 IIS web.config 转换为 Apache .htaccess
我见过很多关于如何从 .htaccess 转到 web.config 的问题。从 web.config 到 .htaccess 的其他方式似乎没有太多问题。
这是我需要转换为 .htaccess 文件的配置文件:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{R:1}" pattern="^(cms|css|files|images|js|themes|index\.php)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/{R:1}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="login">
<add key="http://server/cms/index.php?S=0&D=cp&C=login&M=login_form" value="http://server/login" />
</rewriteMap>
</rewriteMaps>
</rewrite>
<httpErrors>
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/error404" responseMode="ExecuteURL" />
<error statusCode="403" prefixLanguageFilePath="" path="/error403" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
其中有一些部分我不确定,这就是阻止我自己解决这个问题的原因。
第一个是第一条规则的“条件”部分。我不确定如何将其转换为 .htaccess 规则。
第二个是“httpErrors”部分。我可能只是脑子里放屁了,但我不记得如何在 .htaccess 文件中做到这一点。
非常感谢任何帮助!
干杯。
I've seen many questions on how to go from an .htaccess to a web.config. There don't seem to be many questions about going the other way, from web.config to .htaccess.
Here's the configuration file I need to convert into an .htaccess file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Imported Rule 1" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{R:1}" pattern="^(cms|css|files|images|js|themes|index\.php)" negate="true" />
</conditions>
<action type="Rewrite" url="/index.php/{R:1}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="login">
<add key="http://server/cms/index.php?S=0&D=cp&C=login&M=login_form" value="http://server/login" />
</rewriteMap>
</rewriteMaps>
</rewrite>
<httpErrors>
<remove statusCode="403" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/error404" responseMode="ExecuteURL" />
<error statusCode="403" prefixLanguageFilePath="" path="/error403" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>
There are a few parts of this that I'm not sure about, and that's what's preventing me from figuring this out on my own.
The first is the 'conditions' part of the first rule. I'm not sure how to convert that to an .htaccess rule.
The second is the 'httpErrors' section. I'm probably just having a brain fart, but I can't remember how to do that in an .htaccess file.
Any help is much appreciated!
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是除了 RewriteMap 之外的所有内容,您无法在 .htaccess 中执行此操作
Here is everything except RewriteMap, which you cannot do in .htaccess