简体   繁体   中英

URL rewriting on IIS

I'm trying to get some redirects to work and I'm failing at every turn. I know this is really simple. I'm just not getting it.

I'm working on IIS 10 on Windows 10 locally and IIS 7 in production.

/standard-admin/documents/
to
/standard-admin/index.php?url=documents

and

 /standard-admin/admin/documents/
 to
 /standard-admin/admin/index.php?url=documents

and

/standard-admin/admin/documents/add/
to
/standard-admin/admin/index.php?url=documents-add

I was trying:

standard-admin\/([a-z-]+\/)([a-z-]+\/)?([a-z-]+\/)?

Any help is appreciated. Thanks

I've spent hours trying to figure this out and I've looked at many different tutorials, examples, walk-throughs, etc.

I went with this and it seems to be working for now:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="1" stopProcessing="true">
                    <match url="^standard-admin/admin/([\w-]+)/([\w-]+)?/?" />
                    <action type="Rewrite" url="/standard-admin/admin/index.php?area={R:1}&amp;action={R:2}" logRewrittenUrl="true" />
                </rule>
                <rule name="2" enabled="true">
                    <match url="^standard-admin/([\w-]+)/" />
                    <action type="Rewrite" url="/standard-admin/index.php?area={R:1}" logRewrittenUrl="true" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

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