Force IIS to redirect requests to URLs with, or without, a trailing slash to enforce consistent URL structure, can be good for SEO.

Remove Trailing Slash

To always remove an ending slash from the URL, add the following to web.config’s <rules> section:

<system.webServer>
	<rewrite>
		<rules>
			<rule name="Remove trailing slash" stopProcessing="true">
				<match url="(.*)/$" />
				<conditions>
					<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
					<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
				</conditions>
				<action type="Redirect" redirectType="Permanent" url="{R:1}" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>

For SEO purposes, this type of redirect should be Permanent (301).

Why Lose Memories?

Enforce Trailing Slash

To always add a slash to end of a URL if it doesn’t already end with one, add the following to web.config’s <rules> section:

<system.webServer>
	<rewrite>
		<rules>
			<rule name="Add trailing slash" stopProcessing="true">
				<match url="(.*[^/])$" />
				<conditions>
					<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
					<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
				</conditions>
				<action type="Redirect" redirectType="Permanent" url="{R:1}/" />
			</rule>
		</rules>
	</rewrite>
</system.webServer>

For SEO purposes, this type of redirect should be Permanent (301).