Monday 4 May 2009

IIS7 - 301 redirect at the page level

In IIS6 redirecting individual pages properly (using a 301 redirect) was a little tedious, you had to create a physical page as a stub then poke around in the settings to forward requests on to the new location.

IIS7 is a little easier, for those of you who are familiar already it won't suprise you that it's just another line in the good old web.config...


<location path="index2.html">
<system.webServer>
<httpRedirect enabled="true" destination="Default.aspx" exactDestination="true" childOnly="true" httpResponseStatus="Permanent" />
</system.webServer>
</location>


If you place the above snippet inside the tag for each file you wish to redirect, simple!

IIS7 - Change Site Logs Location via Powershell

For anybody out there who just wants to know a simple line of Powershell to change the logging directory of an IIS7 website, here it is:

Set-ItemProperty 'IIS:\Sites\Default Web Site' -name logFile.directory -value 'D:\IISLogs'

Enjoy...