IIS - web.config аналогичный стандартному .htaccess

2

За основу взят файл https://github.com/webasyst/webasyst-framework/blob/master/.htaccess .

Добавил немного от себя: кеширование шрифтов, блокирование доступа к ".*" файлам.

Скачать отдельным файлом с github

<?xml version="1.0"?>
<configuration>
<system.webServer>
<directoryBrowse enabled="false" />
<defaultDocument>
<files>
<clear />
<add value="index.php" />
</files>
</defaultDocument>
<security>
<requestFiltering>
<fileExtensions>
<add fileExtension=".md" allowed="false" />
<add fileExtension=".md5" allowed="false" />
<add fileExtension=".gitignore" allowed="false" />
<add fileExtension=".htaccess" allowed="false" />
</fileExtensions>
</requestFiltering>
</security>
<rewrite>
<rules>
<rule name="Webasyst Controller" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{URL}" pattern="!\.(eot|ttf|woff|js|css|jpg|jpeg|gif|png)$" negate="true" />
<add input="{URL}" pattern="apple-touch-icon\.png$" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
</rules>
</rewrite>
<caching>
<profiles>
<add extension=".eot" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".ttf" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".woff" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".js" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".css" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".jpg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".jpeg" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".gif" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
<add extension=".png" policy="CacheForTimePeriod" kernelCachePolicy="CacheForTimePeriod" duration="10:00:00:00" />
</profiles>
</caching>
</system.webServer>
</configuration>

2 комментария

  • +1
    Игорь Игорь 9 ноября 2015 04:32 #

    добрый день

    я тоже решил попробовать IIS, так как выходит явно быстрее apache

    у меня вопрос - вы тут привели конфиг только для одного файла, для верхнего в иерарархии. А ведь там .htaccess файлов может быть и две сотни

    например


    <FilesMatch "\.(php\d?|html?|xml)$">

    Deny from all

    </FilesMatch>


    как вы с это победили? неужели руками писали конфиги? или обошлись чем-то аля helicon ape ?

  • +1
    Игорь Игорь 11 ноября 2015 04:34 #

    по ходу ваш вариант не работает. надо думать..

    Добавление новых комментариев к этой теме отключено.