问题描述:

After looking for the answer for hours, I need to ask. Let's say I have this web.config file that successfully redirects my 404 error page on my windows 2008 server:

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<system.webServer>

<defaultDocument enabled="true">

<files>

<clear />

<add value="index.aspx" />

<add value="index.asp" />

<add value="index.htm" />

<add value="index.html" />

<add value="home.aspx" />

<add value="home.asp" />

<add value="home.htm" />

<add value="home.html" />

<add value="default.aspx" />

<add value="default.asp" />

<add value="default.htm" />

<add value="default.html" />

</files>

</defaultDocument>

<security>

<authentication>

<basicAuthentication enabled="true" />

</authentication>

</security>

<httpErrors errorMode="Custom">

<remove statusCode="404" subStatusCode="-1" />

<error statusCode="404" prefixLanguageFilePath="" path="/404.html" responseMode="ExecuteURL" />

</httpErrors>

</system.webServer>

</configuration>

I want to change the path that does not start with www to start with www with the xml below. I'm having issues integrating it as it gives me a 500 error (mind you I'm not a very strong developer).

<rewrite>

<rules>

<rule name="Redirect domain.com to www" patternSyntax="ECMAScript" stopProcessing="true">

<match url=".*" />

<conditions>

<add input="{HTTP_HOST}" pattern="^domain.com$" />

</conditions>

<action type="Redirect" url="http://www.domain.com/{R:0}" />

</rule>

</rules>

</rewrite>

Any help would be greatly appreciated! I've spent hours looking for an answer without success.

相关阅读:
Top