Overview
Internet Information Services (IIS) powers your Windows hosting. While you dont have direct server access, you can configure many IIS settings through Plesk and the web.config file.
Understanding web.config
The web.config file controls IIS behavior for your website. Place it in your document root (httpdocs).
Basic Structure:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<!-- IIS settings go here -->
</system.webServer>
</configuration>
Common IIS Configurations
Custom Error Pages
<system.webServer>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" path="/errors/404.html" responseMode="ExecuteURL" />
<remove statusCode="500" />
<error statusCode="500" path="/errors/500.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
URL Redirects (301)
<system.webServer>
<rewrite>
<rules>
<rule name="Redirect old page" stopProcessing="true">
<match url="^old-page.html$" />
<action type="Redirect" url="/new-page" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
Force HTTPS
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="^OFF$" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
Force WWW (or non-WWW)
<!-- Force WWW -->
<rule name="Add WWW" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(?!www.)(.*)$" />
</conditions>
<action type="Redirect" url="https://www.{HTTP_HOST}/{R:1}" redirectType="Permanent" />
</rule>
Default Documents
<system.webServer>
<defaultDocument>
<files>
<clear />
<add value="index.html" />
<add value="default.aspx" />
<add value="index.aspx" />
</files>
</defaultDocument>
</system.webServer>
Block IP Addresses
<system.webServer>
<security>
<ipSecurity allowUnlisted="true">
<add ipAddress="123.456.789.0" allowed="false" />
</ipSecurity>
</security>
</system.webServer>
MIME Types
<system.webServer>
<staticContent>
<mimeMap fileExtension=".webp" mimeType="image/webp" />
<mimeMap fileExtension=".woff2" mimeType="font/woff2" />
</staticContent>
</system.webServer>
Plesk IIS Settings
Accessing IIS Settings in Plesk:
- Go to Websites & Domains
- Select your domain
- Click Hosting Settings
Available Options:
- Document root: Change the web folder location
- SSL/TLS: Enable HTTPS
- Preferred domain: WWW or non-WWW
Application Pool (Info Only)
Your site runs in an IIS Application Pool. Key points:
- ASP.NET Core apps use "No Managed Code"
- ASP.NET Framework apps use the appropriate .NET version
- Contact support if you need pool settings changed
Troubleshooting web.config
500 Error After Adding web.config:
- Validate XML syntax (use an XML validator)
- Check for duplicate sections
- Ensure URL Rewrite module is available (contact support)
Testing Changes:
- Make a backup of your current web.config
- Make changes incrementally
- Test after each change
- Check browser for specific error messages