aboutsummaryrefslogtreecommitdiffhomepage
path: root/main/webserver-configs/web.config
blob: 96b3a00c25d00b7e06fed6f662aa64cea873a6bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?xml version="1.0" encoding="UTF-8"?>
<!-- Unlike apache and *ngix, IIS will likely require additional configuration that cannot be safely defined, or defined at all in a web.config file.
     If odd behaviour occurs:
     1. Ensure web.config settings are being applied, as IIS can be configured to ignore specific web.config settings.
     2. If there is an IIS error page, try the suggested solutions.
     3. See if anyone on the web has encountered the same issue, and try the suggested solutions.
     4. And as a last resort, ask in the UserFrosting chat support channel. http://chat.userfrosting.com -->
<configuration>
    <system.webServer>
        <!-- Most default installs of PHP in IIS only accept GET and POST HTTP verbs.
             If using the account functionality of UserFrosting, additional HTTP verbs will need to be added to the PHP handler.
             Specifically, PUT and DELETE are required.
             Sample PHP handler definition follows.
        <handlers> 
            <add name="PHP_via_FastCGI" path="*.php" verb="GET,POST,PUT,DELETE" modules="FastCgiModule" scriptProcessor="path/to/php/directory/php-cgi.exe" resourceType="Either" />
        </handlers>-->
        <rewrite>
            <!-- Rules to clean url, and ensure requests are handled by PHP when appropriate. -->
            <rules>
                <!-- Clear any inherited rules -->
                <clear />
                <!-- Dynamically rewrite base directory to remove index.php from url. -->
                <rule name="Remove .../index.php/... from url">
                    <match url="^index\.php/(.*)$" />
                    <action type="Redirect" redirectType="Permanent" url="{R:1}" />
                </rule>
                <!-- Remove trailing slash from any non-directory path (canonicalization) - GET requests only. -->
                <rule name="Remove trailing slash">
                    <match url="(.*)/$" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Redirect" redirectType="Permanent" url="{R:1}" />
                </rule>
                <!-- Send the URI to index.php (Slim routing) if url maps to neither a directory, or file. -->
                <rule name="Rewrite to index.php" stopProcessing="true">
                    <match url=".*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILEDIR}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
        <!-- Set index.php as default document, and clear inherited defaults. -->
        <defaultDocument enabled="true">
            <files>
                <clear />
                <add value="index.php" />
            </files>
        </defaultDocument>
        <!-- Whitelist specific static file types -->
        <staticContent>
            <!-- Clear inherited rules -->
            <clear />
            <!-- Set content expiration time (31 days for every static file listed) -->
            <!--<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="31.00:00:00" />-->
            <!-- Atom feeds -->
            <mimeMap fileExtension=".atom" mimeType="application/atom+xml" />
            <mimeMap fileExtension=".xml" mimeType="application/atom+xml, application/rss+xml, application/xhtml+xml, application/xml, text/xml" />
            <!-- JS -->
            <mimeMap fileExtension=".js" mimeType="application/js" />
            <!-- JSON -->
            <mimeMap fileExtension=".json" mimeType="application/json" />
            <!-- EOT font -->
            <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
            <!-- TTF fonts -->
            <mimeMap fileExtension=".ttf" mimeType="application/x-font-ttf" />
            <!-- Web App Manifest -->
            <mimeMap fileExtension=".webapp" mimeType="application/x-web-app-manifest+json" />
            <!-- XHTML -->
            <mimeMap fileExtension=".xhtml" mimeType="application/xhtml+xml" />
            <mimeMap fileExtension=".xht" mimeType="application/xhtml+xml" />
            <mimeMap fileExtension=".html" mimeType="application/xhtml+xml" />
            <mimeMap fileExtension=".htm" mimeType="application/xhtml+xml" />
            <!-- Images -->
            <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
            <mimeMap fileExtension=".png" mimeType="image/png" />
            <mimeMap fileExtension=".ico" mimeType="image/x-icon" />
            <!-- WOFF/2 fonts -->
            <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
            <mimeMap fileExtension=".woff2" mimeType="font/woff2" />
            <!-- CSS -->
            <mimeMap fileExtension=".css" mimeType="text/css" />
            <!-- Plain text -->
            <mimeMap fileExtension=".txt" mimeType="text/plain" />
            <!-- HTML Component -->
            <mimeMap fileExtension=".htc" mimeType="text/x-component" />
        </staticContent>
    </system.webServer>
</configuration>