简体   繁体   English

Apache .htaccess将规则重写为IIS web.config规则

[英]Apache .htaccess rewrite rule to IIS web.config rule

I am moving a PHP application from Apache to IIS server. 我正在将PHP应用程序从Apache迁移到IIS服务器。 I am trying to translate the following .htaccess rule: 我正在尝试转换以下.htaccess规则:

RewriteEngine On
RewriteRule ^(.*)$ public/$1?%{QUERY_STRING} [QSA,L]

It simply redirects all requests (as well as query string) to public subdirectory. 它只是将所有请求(以及查询字符串)重定向到public子目录。

I have tried something like the following in web.config file- 我已经在web.config文件中尝试了以下内容-

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
    <rewrite>
        <rules>
            <rule name="Root Hit Redirect" stopProcessing="true">
                <match url="^$" />
                <action type="Redirect" url="/public/index.php" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>
</configuration>

But it keeps falling into redirect loop. 但是它一直陷入重定向循环。 What should be correct web.config rule in this case? 在这种情况下,正确的web.config规则应该是什么?

Managed to solve this by importing rules in IIS. 通过在IIS中导入规则来解决此问题。

http://akrabat.com/winphp-challenge/zend-framework-url-rewriting-in-iis7/ http://akrabat.com/winphp-challenge/zend-framework-url-rewriting-in-iis7/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM