简体   繁体   中英

Apache .htaccess rewrite rule to IIS web.config rule

I am moving a PHP application from Apache to IIS server. I am trying to translate the following .htaccess rule:

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

It simply redirects all requests (as well as query string) to public subdirectory.

I have tried something like the following in web.config file-

<?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?

Managed to solve this by importing rules in IIS.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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