httpRedirect - Redirect from http://www.*.com to http://*.com
I'm running IIS7 and I need to setup a redirect in my web config - in the httpRedirect...
What I need to do is up a couple permanent redirect:
- http://www.*.com to http://*.com开发者_运维问答, and
- http://*.com/test.html to http://*.com/test
Here is a rule for IIS7 that will work for your first requirement. The RedirectType is permanent (301).
<rewrite>
<rules>
<rule name="test" stopProcessing="true">
<match url="^www\.(\w+\.com)$" />
<action type="Redirect" url="http://{R:1}" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
Your second requirement will require the following rules:
<rewrite>
<rules>
<rule name="RedirectUserFriendlyURL" stopProcessing="true">
<match url="^domain\.com/test\.html$" />
<conditions>
<add input="{REQUEST_METHOD}" negate="true" pattern="^POST$" />
</conditions>
<action type="Redirect" url="domain.com/test" appendQueryString="false" redirectType="Permanent" />
</rule>
<rule name="RewriteUserFriendlyURL" stopProcessing="true">
<match url="^domain\.com/test$" />
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="domain.com/test.html" />
</rule>
</rules>
</rewrite>
These rules will rewrite http://domain.com/test.html
to http://domain.com/test
.
You may need to change some of the settings to fit your needs.
精彩评论