<?xml version="1.0" encoding="UTF-8"?>
<configuration>
	<system.webServer>
		<defaultDocument>
			<files>
				<clear />
				<add value="index.php" />
				<add value="index.html" />
			</files>
		</defaultDocument>
		<httpErrors>
			<remove statusCode="403" subStatusCode="-1" />
			<remove statusCode="404" subStatusCode="-1" />
			<error statusCode="403" path="/403.html" responseMode="ExecuteURL" />
			<error statusCode="404" path="/404.html" responseMode="ExecuteURL" />
		</httpErrors>
		<staticContent>
			<remove fileExtension=".oga" />
			<mimeMap fileExtension=".oga" mimeType="audio/ogg" />
			<remove fileExtension=".ogv" />
			<mimeMap fileExtension=".ogv" mimeType="video/ogg" />
			<remove fileExtension=".ogg" />
			<mimeMap fileExtension=".ogg" mimeType="video/ogg" />
			<remove fileExtension=".webm" />
			<mimeMap fileExtension=".webm" mimeType="video/webm" />
			<remove fileExtension=".ttf" />
			<mimeMap fileExtension=".ttf" mimeType="font/ttf" />
			<remove fileExtension=".eot" />
			<mimeMap fileExtension=".eot" mimeType="font/eot" />
			<remove fileExtension=".woff" />
			<mimeMap fileExtension=".woff" mimeType="font/woff" />
			<remove fileExtension=".woff2" />
			<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
		</staticContent>
		<rewrite>
			<rules>
				<rule name="Acme-challenge test" stopProcessing="true" enabled="true">
					<match url="^\.well-known\/acme-challenge\/" ignoreCase="false" />
					<action type="None" />
				</rule>
				<rule name="Dot started restrictions" stopProcessing="true" enabled="true">
					<match url="^(\.|/\.)" ignoreCase="false" />
					<action type="Redirect" redirectType="Temporary" url="{R:0}" />
				</rule>
				<rule name="Kill WWW-prefix" stopProcessing="true" enabled="true">
					<match url="^" ignoreCase="false" />
					<conditions>
						<add input="{HTTP_HOST}" pattern="^www\." ignoreCase="false" />
						<add input="{HTTPS}s" pattern="^on(s)|off" ignoreCase="false" />
						<add input="http{C:1}://{HTTP_HOST}" pattern="^(https?://)(www\.)?(.+)$" ignoreCase="false" />
					</conditions>
					<action type="Redirect" redirectType="Permanent" url="{C:1}{C:3}{URL}" />
				</rule>
				<rule name="Redirect links with index.php only" stopProcessing="true" enabled="true">
					<match url="^(.*?)index\.php$" />
					<conditions logicalGrouping="MatchAll">
						<add input="{REQUEST_METHOD}" pattern="GET" ignoreCase="false" />
						<add input="{QUERY_STRING}" pattern="^$" ignoreCase="false" />
						<add input="{REQUEST_URI}" pattern="index.php" />
					</conditions>
					<action type="Redirect" redirectType="Permanent" url="/{R:1}" />
				</rule>
				<rule name="Also cut trailing question mark" stopProcessing="true" enabled="false">
					<match url="^(.*)$" ignoreCase="false" />
					<conditions>
						<add input="{THE_REQUEST}" pattern="^[^\s]+\s+[^?]*?\?$" ignoreCase="false" />
						<add input="{QUERY_STRING}" pattern="^$" ignoreCase="false" />
					</conditions>
					<action type="Redirect" redirectType="Permanent" url="/{R:1}?" appendQueryString="false" />
				</rule>
				<rule name="Redirect to SSL STANDART MODE" stopProcessing="true" enabled="true">
					<match url="^(.*)$" ignoreCase="false" />
					<conditions>
						<add input="{HTTPS}" pattern="off" ignoreCase="false" />
					</conditions>
					<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
				</rule>
				<rule name="Send all blocked request to homepage with 403 Forbidden error!" stopProcessing="true" enabled="true">
					<match url="^(.*)$" ignoreCase="false" />
					<conditions logicalGrouping="MatchAny">
						<add input="{QUERY_STRING}" pattern="base64_encode.*\(.*\)" ignoreCase="false" />
						<add input="{QUERY_STRING}" pattern="(\&lt;|%3C).*script.*(\&gt;|%3E)" />
						<add input="{QUERY_STRING}" pattern="GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
						<add input="{QUERY_STRING}" pattern="_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ignoreCase="false" />
					</conditions>
					<action type="CustomResponse" url="index.php" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
				</rule>
				<rule name="Rewrite referral SEF link to simple link" stopProcessing="true" enabled="true">
					<match url="^ref_(.*).html$" ignoreCase="false" />
					<action type="Rewrite" url="/index.php?referral={R:1}" appendQueryString="false" />
				</rule>
				<rule name="Search engine 1" stopProcessing="true" enabled="true">
					<match url="^(search).html$" ignoreCase="false" />
					<action type="Rewrite" url="/index.php?task={R:1}" appendQueryString="true" />
				</rule>
				<rule name="Search engine 2" stopProcessing="true" enabled="true">
					<match url="^(search)/(any|exact|all)/(.*).html$" ignoreCase="false" />
					<action type="Rewrite" url="/index.php?task={R:1}&amp;searchtype={R:2}&amp;where_search={R:3}" appendQueryString="true" />
				</rule>
				<rule name="Check administrator urls" stopProcessing="true" enabled="true">
					<match url="(.*)" ignoreCase="false" />
					<conditions>
						<add input="{R:1}" pattern="^(admin_folder)" ignoreCase="false" />
						<add input="{R:1}" pattern="^(admin_folder|admin_folder/|admin_folder/index\.php|admin_folder/exchange1c\.php)$" ignoreCase="false" negate="true" />
						<add input="{URL}" pattern="(/|\.php|\.html|\.htm|/[^.]*)$" />
					</conditions>
					<action type="Redirect" redirectType="Temporary" url="/index.php" />
				</rule>
				<rule name="Check if html, ico, txt, xml file in root" stopProcessing="true" enabled="true">
					<match url="^(.*)$" ignoreCase="false" />
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
						<add input="{URL}" pattern="(\.html|\.ico|\.txt|\.xml)$" ignoreCase="false" />
						<add input="{URL}" pattern="^(.+)/" ignoreCase="false" negate="true" />
					</conditions>
					<action type="Rewrite" url="{R:1}" />
				</rule>
				<rule name="Check if ico, css, js file exists" stopProcessing="true" enabled="true">
					<match url="^(.*)$" ignoreCase="false" />
					<conditions>
					<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" />
					<add input="{URL}" pattern="(\.ico|\.css|\.js)$" ignoreCase="false" />
					</conditions>
					<action type="Rewrite" url="{R:1}" />
				</rule>
				<rule name="Return 404 for absent ico, css, js file" stopProcessing="true" enabled="true">
					<match url="." />
					<conditions>
						<add input="{REQUEST_FILENAME}" matchType="IsFile" ignoreCase="false" negate="true" />
						<add input="{URL}" pattern="(\.ico|\.css|\.js)$" ignoreCase="false" />
						<add input="{URL}" pattern="^(.+)/" ignoreCase="false" negate="true" />
					</conditions>
					<!-- <action type="Redirect" redirectType="Temporary" url="{R:0}" /> -->
					<action type="CustomResponse" url="/" statusCode="404" />
				</rule>
				<rule name="Non administrator url redirect" enabled="true">
					<match url="(.*)" ignoreCase="false" />
					<conditions>
						<add input="{R:1}" pattern="^(admin_folder|assets|data|templates)" ignoreCase="false" negate="true" />
						<add input="{R:1}" pattern="^(index\.php)$" ignoreCase="false" negate="true" />
					</conditions>
					<action type="Rewrite" url="/index.php" />
				</rule>
			</rules>
		</rewrite>
	</system.webServer>
</configuration>
