web.config file index redirect not working.

i am trying to set up a redirect on my index pages and www or non www to redirect all to the main address.
http://www.address.com
I tried 2 different approaches and both aren't working.
 <system.webServer>
        <rewrite>
            <rules>
 

<rule name="CanonicalHostNameRule1" enabled="false">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{HTTP_HOST}" pattern="^www\.site\.com$" negate="true" />
<add input="{HTTP_HOST}" pattern="^1\.2\.3\.4$" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://www.site.com/{R:1}" />
                </rule>
				<rule name="INDEX FILES" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
                    <match url="index.*" />
                    <action type="Redirect" url="/" appendQueryString="true" />
                </rule>
		
				</rules>
				</rewrite>
				</system.webServer>

Open in new window

what did i do wrong in my config file?
rivkamakAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GaryCommented:
Which IIS?
Bit confused - you want to redirect everything to your main page?
0
rivkamakAuthor Commented:
My site is sitting on a godaddy windows server.
This is what I am trying to do.

http://site.com/
http://site.com/index.html
http://www.site.com/
http://www.site.com/index.html

should redirect to http://www.site.com/
0
Emmanuel AdebayoGlobal Windows Infrastructure Engineer - ConsultantCommented:
Have you had iis rewrite module enabled?

Also see the solution I provided for similar rule

http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Microsoft_IIS/Q_28224225.html

Regards
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
GaryCommented:
<rule name="redirec index.html to home" stopProcessing="true">
	<match url="index\.html(?:l)?" />
	<conditions>
		<add input="{HTTP_HOST}" pattern="site\.com$" />
	</conditions>
	<action type="Redirect" url="http://www.site.com/{R:301}" />
</rule>

<rule name="redirect non www to www" stopProcessing="true">
	<match url="(.*)" />
	<conditions>
		<add input="{HTTP_HOST}" pattern="^site\.com$" />
	</conditions>
	<action type="Redirect" url="http://www.site.com/{R:301}" />
</rule>

Open in new window

Not my strong area so may need tweaking
And good point by giveandtake638
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.