Hey guys,
I use a standard web.config file for my projects that are hosted on Windows servers. It takes care of 2 tasks.
1. It redirects the non-www version of the site to the www version.
2. It redirects the index file to the root.
See below:
This works great, except for 1 problem. The index redirect is redirecting all sub-directories to the main, index.Code:<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <modules runAllManagedModulesForAllRequests="true" /> <rewrite> <rules> <rule name="CanonicalHostNameRule1" stopProcessing="true"> <match url="index\.asp(?:l)?" /> <conditions> <add input="{HTTP_HOST}" pattern="domain\.com$" /> </conditions> <action type="Redirect" url="http://www.domain.com/" /> </rule> <rule name="CanonicalHostNameRule2" stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="^domain\.com$" /> </conditions> <action type="Redirect" url="http://www.domain.com/{R:1}" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
For example:
http://www.domain.com/index.asp is redirecting to http://www.domain.com like it should.
But, http://www.domain.com/about/index.asp is also redirecting to http://www.domain.com.
I would like it to redirect to http://www.domain.com/about/
Any help would be greatly appreciated.


Reply With Quote

Bookmarks