简体   繁体   中英

how convert htaccess deny rule to IIS url rewrite rule

I am converting .htaccess file to rewrite rules in IIS to convert from http to https, all the rules are being converted which starts with RewriteCond but deny from all is not converted

I want to convert this htaccess rule to IIS rewrite rule

<Files ~ "\.log$">
Deny from all
</Files>

Is there any other way to convert it? or I doing something wrong.

to convert this rule you could use the request filtering feature of iis or URL rewrite.

<configuration>
        <security>
            <requestFiltering>
                <fileExtensions>
                    <add fileExtension=".log" allowed="false" />
                </fileExtensions>
            </requestFiltering>
        </security>
    </system.webServer>
</configuration>

using url rewrite rule:

<rule name="Protect files and directories from prying eyes" stopProcessing="true"> 
    <match url="\.log$" /> 
    <action type="CustomResponse" statusCode="403" subStatusCode="0" statusReason="Forbidden" statusDescription="Access is forbidden." /> 
</rule>

for more detail please refer this link:

https://docs.microsoft.com/en-us/iis/application-frameworks/install-and-configure-php-applications-on-iis/translate-htaccess-content-to-iis-webconfig#request-filtering

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