1

I am running an ASP.NET 4.0 website using IIS7 on Windows Server 2008 R2.

The site has a number of Web Applications under the main domain (~/site1, ~/site2, ~/site3, etc...). Each Web Application is an instance of the same website source folder (D:\Websites\MySite), so you can access the same website at any of the following URLs:

www.mydomain.com

www.mydomain.com/site1

www.mydomain.com/site2

www.mydomain.com/site3

The same website is returned each time, but with slightly different content depending on which specific URL is called.

Everything has been working fine for months until I was asked to add some SEO optimizations using URL Rewrite. Every URL Rewrite rule I add produces the following error:

HTTP Error 500.52 - URL Rewrite Module Error. The page cannot be displayed because an internal server error has occurred.

Config Error: Cannot add duplicate collection entry of type 'rule' with unique key attribute 'name' set to 'AddTrailingSlashRule1'

I have read elswhere that surrounding the <system.webServer> configSection in the web.config file with:

<location path="." inheritInChildApplications="false">

will fix this problem.

However, while it stops the error message from appearing, it also stops the URL Rewrite rules from working in any of the Web Applications (~/site1, ~/site2, ~/site3).

How can I get the URL Rewrite module to work with Web Applications?

Thanks for any help you can offer.

0

For Example:

www.mydomain.com's html file name as main.html

www.mydomain.com/site 1's file name as site 1.html ..etc

Step 1: win+R type "inetsrv" without quote press Enter --> config --> open applicationHost.config file (use notepad ++)

step 2: Find Out below the line (approximately line number = 218)

<defaultDocument enabled="true">
            <enter code here`files>
                <add value="Default.htm" />
                <add value="Default.asp" />
                <add value="index.htm" />
                <add value="index.html" />
                <add value="iisstart.htm" />
                <add value="default.aspx" />

            </files>
        </defaultDocument>

step3 : Add www.mydomain.com file name

Example

<add value="main.html" />

and save

step 4: open IIS and go to site 1 --> open default document -->press add and enter site 1's file name (site1.html)

step 5:

Open your web.config file paste the lines

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
     <location path="site 1">
       <system.webServer>
       <defaultDocument enabled="true">
         <files>
            <clear />
              <add value="site1.html" />
         </files>
        </defaultDocument>
    </system.webServer>
    </location>
 </configuration>

-------------------------------------------------- and save

step 6: site 2 same as site 1 (change location path as "site 2" and html file name)

Example:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
     <location path="site 1">
       <system.webServer>
       <defaultDocument enabled="true">
         <files>
            <clear />
              <add value="site1.html" />
         </files>
        </defaultDocument>
    </system.webServer>
    </location>
    <location path="site 2">
       <system.webServer>
       <defaultDocument enabled="true">
         <files>
            <clear />
              <add value="site2.html" />
         </files>
        </defaultDocument>
    </system.webServer>
    </location>
  </configuration>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.