简体   繁体   中英

htaccess to Web.Config conversion

I want to convert below portion of .htaccess to Web.Config.I tried many times but its not working properly.please could anyone help me.

       RewriteCond %{REQUEST_URI} ^/2007/(admin)
       RewriteCond %{REQUEST_URI} !^/2017/(frontend|backend)/web/(assets|css|js|files|uploads)/

Your .htaccess is a bit complicated, I think that there is an easier and efficient way. Anyway, web config is a torture; and IISs import htaccess feature is a bad joke. This solution works for me:

<configuration>
 <configSections>
    <sectionGroup name="system.webServer">
        <sectionGroup name="rewrite">
            <section name="rewriteMaps" overrideModeDefault="Allow" />
            <section name="rules" overrideModeDefault="Allow" />
        </sectionGroup>
    </sectionGroup>
  </configSections>
  <system.webServer>
    <rewrite>
        <rules>
            <rule name="rule backend js deal" stopProcessing="true">
                <match url="^admin/js/(.*)$" />
                <action type="Rewrite" url="/backend/web/js/{R:1}" />
            </rule>
            <!-- the other assets here -->

            <!-- this must be BEFORE frontend rule -->
            <rule name="rule admin url deal" stopProcessing="true">
                <match url="^admin(.*)$" />
                <action type="Rewrite" url="/backend/web/index.php" />
            </rule>
    </rewrite>
 </system.webServer>
</configuration>

Check this solution from backend, and apply to frontend. If you have some problem with some url, please, write me.

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