questions

Convert htaccess rule to config.web on windows server

Rate this post

I need to use this rule on a Plesk Windows server.

RewriteCond %{REQUEST_URI} ^\/(invoice|offer)\/(.*) [NC]
RewriteRule ^(.*)$ https://dev.domain.com/$1 [R=301,NC,L]

Can someone show me how to use this rule in the web.conf file?

 

✔️Solution:

The resulting web.config should look similar to this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="Rule 1" stopProcessing="true">
                    <match url="^(.*)$"/>
                    <conditions>
                        <add input="{URL}" pattern="^\/(invoice|offer)\/(.*)"/>
                    </conditions>
                    <action type="Redirect" redirectType="Permanent" url="https://dev.domain.com/{R:1}"/>
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Leave a Reply

Your email address will not be published.

Back to top button