- 
	
	
	
		
Web.Config
	
	
		Hi,
I'm forced to move Contao 3.5 to a windows server. I'm having trouble enabling "Rewrite URLs" and "Enable folder URLs". I've tried to convert the .htaccess file to Web.Config, but I don't get a desired result.
Here is my .htaccess file: 
	Code:
	
<FilesMatch "\.(tpl|html5|xhtml)$">
  <IfModule !mod_authz_core.c>
    Order deny,allow
    Deny from all
  </IfModule>
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
</FilesMatch>
<IfModule mod_headers.c>
  <FilesMatch "\.(ttf|ttc|otf|eot|woff2?|font\.css)$">
    Header set Access-Control-Allow-Origin "*"
  </FilesMatch>
</IfModule>
FileETag None
<IfModule mod_headers.c>
  Header unset ETag
</IfModule>
<IfModule mod_mime.c>
  AddType application/javascript              js jsonp
  AddType application/json                    json
  AddType audio/ogg                           oga ogg
  AddType audio/mp4                           m4a f4a f4b
  AddType video/ogg                           ogv
  AddType video/mp4                           mp4 m4v f4v f4p
  AddType video/webm                          webm
  AddType video/x-flv                         flv
  AddType image/svg+xml                       svg svgz
  AddEncoding gzip                            svgz
  AddType application/vnd.ms-fontobject       eot
  AddType application/x-font-ttf              ttf ttc
  AddType font/opentype                       otf
  AddType application/x-font-woff             woff woff2
  AddType image/x-icon                        ico
  AddType image/webp                          webp
  AddType text/cache-manifest                 appcache manifest
  AddType text/x-component                    htc
  AddType application/xml                     rss atom xml rdf
  AddType application/x-web-app-manifest+json webapp
  AddType text/x-vcard                        vcf
  AddType application/x-shockwave-flash       swf
</IfModule>
<IfModule mod_deflate.c>
  <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE text/xml application/xml text/x-component
    AddOutputFilterByType DEFLATE application/xhtml+xml application/rss+xml application/atom+xml
    AddOutputFilterByType DEFLATE image/x-icon image/svg+xml application/vnd.ms-fontobject application/x-font-ttf font/opentype
  </IfModule>
</IfModule>
<IfModule mod_expires.c>
  ExpiresActive on
  ExpiresByType text/cache-manifest           "access plus 0 seconds"
  ExpiresByType text/html                     "access plus 0 seconds"
  ExpiresByType text/xml                      "access plus 0 seconds"
  ExpiresByType application/xml               "access plus 0 seconds"
  ExpiresByType application/json              "access plus 0 seconds"
  ExpiresByType application/rss+xml           "access plus 1 hour"
  ExpiresByType application/atom+xml          "access plus 1 hour"
  ExpiresByType image/gif                     "access plus 1 month"
  ExpiresByType image/png                     "access plus 1 month"
  ExpiresByType image/jpeg                    "access plus 1 month"
  ExpiresByType image/x-icon                  "access plus 1 month"
  ExpiresByType video/ogg                     "access plus 1 month"
  ExpiresByType audio/ogg                     "access plus 1 month"
  ExpiresByType video/mp4                     "access plus 1 month"
  ExpiresByType video/webm                    "access plus 1 month"
  ExpiresByType text/x-component              "access plus 1 month"
  ExpiresByType application/x-font-ttf        "access plus 1 month"
  ExpiresByType font/opentype                 "access plus 1 month"
  ExpiresByType application/x-font-woff       "access plus 1 month"
  ExpiresByType image/svg+xml                 "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
  ExpiresByType text/css                      "access plus 1 year"
  ExpiresByType application/javascript        "access plus 1 year"
</IfModule>
<IfModule mod_headers.c>
  <FilesMatch "cron\.txt$">
    Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
  </FilesMatch>
  <FilesMatch "\.(js|css|xml|gz|svgz)$">
    Header append Vary Accept-Encoding
  </FilesMatch>
  <FilesMatch "\.map$">
    Header set Expires "0"
    Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0, proxy-revalidate, no-transform"
  </FilesMatch>
</IfModule>
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteCond %{HTTP_HOST} ^mydomain\.com$ [NC]
  RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
  RewriteCond %{REQUEST_FILENAME} !\.(htm|php|js|css|map|htc|png|gif|jpe?g|ico|xml|csv|txt|swf|flv|mp4|webm|ogv|mp3|ogg|oga|eot|otf|tt[cf]|woff2?|svgz?|pdf|zip|gz)$
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule .* index.php [L]
  RewriteRule ^[a-z]{2}(\-[A-Z]{2})?/$ index.php [L]
  RewriteRule ^([a-z]{2}(\-[A-Z]{2})?)$ $1/ [R=301,L]
  RewriteRule ^sitemap\.xml$ /share/sitemap.xml [L,NC,R=301]
</IfModule>
 Does anybody have a Web.Config already converted? Can anybody help, I have not Web.Config experience.
Regard,
Darjan
	 
 - 
	
	
	
	
		Ok,
up to today I came up with this:
	Code:
	
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
              <rule name="Sitemap redirect" stopProcessing="true" patternSyntax="Wildcard">
                <match url="sitemap.xml" />
                <action type="Rewrite" url="share/sitemap.xml" appendQueryString="false" />
              </rule>
              <rule name="Contao" stopProcessing="true">
                <match url="^([^?]*)" />
                <conditions>
                  <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                  <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                  <add input="{REQUEST_URI}" pattern=".*\.(ico|gif|jpg|jpeg|png|js|css)" negate="true" />
                </conditions>
                <action type="Rewrite" url="index.php?{R:1}" appendQueryString="true" />
              </rule>
            </rules>
        </rewrite>
        <staticContent>
            <clientCache cacheControlCustom="public" cacheControlMode="UseMaxAge" cacheControlMaxAge="3.00:00:00" />
        </staticContent>
    </system.webServer>
</configuration>
 Seems to work, but I havent done any testing jet. Anybody else got some solution?
Regard,
Darjan
	 
 - 
	
	
	
	
		I personally never worked on Windows Server, but there is a blog post from the Microsoft Azure team. Maybe you should have a look at it? https://blogs.msdn.microsoft.com/azu...zure-websites/