0

Good afternoon people.

The issue is that I was testing redirecting pages and I ended up having to repeat the code 11 times. But I believe there is a way to automate this. If anyone can help me.

What I want to do is access an address dominio.com/projeto/01/ and he rewrite to dominio.com/projeto/modulo/01 , but I wanted to automate the final part of the url to receive any number and apply that number to the last part of the redirected url

for exemple:

dominio.com/projeto/01/ > dominio.com/projeto/modulo/01

dominio.com/projeto/02/ > dominio.com/projeto/modulo/02

My current web config I do all the links per line

<configuration>
    <system.webServer>
<rewrite>
    <rules>
     <rule name="Projeto" stopProcessing="true">
            <match url="^project/file-01" />
            <action type="Redirect" url="https://dominio.com.br/project/module/file-01/" />
        </rule>
<rule name="Projeto2" stopProcessing="true">
            <match url="^project/file-02" />
            <action type="Redirect" url="https://dominio.com.br/project/module/file-02/" />
        </rule>

    </rules>
</rewrite>
       
     <httpProtocol>
        <customHeaders/>
    </httpProtocol>
    </system.webServer>
</configuration>``` 
  • IIS URL rewrite rules support regular expressions, so you can write a single rule to cover all the cases. Use search engines and you can learn a lot. – Lex Li Nov 29 '22 at 01:13

0 Answers0