Learn how to use web.config to redirect an index file to your root. Windows hosting only.

What does it do?

This rule redirects the index file to your website root. The rule can be added to the web.config file and works with sites hosted on our Windows servers.

For example:

Is automatically redirected to:

Why use this rule?

This web.config rule reduces the chances of duplicate results appearing in the search engines for the same page, improve your sites ranking. This is known as URL canonicalization, or canonical URLs.

Example web.config index redirect

Your web.config file is a critical file so take a backup before making any edits. This way you can restore the file quickly should something going wrong.

To use this rule, add the following code to your existing web.config file.

		<rule name="redirect index.asp" stopProcessing="true">
			<match url="^(\w*/)?index\.php"></match>
			<add input="{HTTP_HOST}" pattern="^domain\.com$"></add>
			<action type="Redirect" url="{R:1}"></action>