Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7187783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:55:24+00:00 2026-05-28T18:55:24+00:00

How to create a 301 redirect in IIS7 using the Rewrite Rule extension for

  • 0

How to create a 301 redirect in IIS7 using the Rewrite Rule extension for IIS (writes to web.config) that will allow redirecting non-www to www – BUT, I don’t want to use (.*), I want the URL rewriter to ignore URLs like DNS ones, so it can work under Amazon Load Balancer. Without it, Amazon Load Balancer will not be able to read the health check file, because it will be redirected and instead of getting 200OK it will get 301.

So I actually need a rule that will match a URL that contains mydomain.com, or one that start with it of course, so it won’t loop.

The current rule is not good:

<rewrite>
  <rules>
    <rule name="CanonicalHostNameRule1">
       <match url="(.*)" />
         <conditions>
           <add input="{HTTP_HOST}" pattern="^www\.mydomain\.com$" negate="true" />
         </conditions>
         <action type="Redirect" url="http://www.mydomain.com/{R:1}" />
    </rule>
 </rules>
</rewrite>

This will redirect URLs like dns.amzn.com to http://www.mydomain.com – I’ve tried it on IIS7.

Need a better solution

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T18:55:26+00:00Added an answer on May 28, 2026 at 6:55 pm

    did you come with a solution..

    i added a condition using {HTTP_USER_AGENT} to not match ELB (user agent).
    This stopped the rule from running for ELB, but i’m just testing this at the moment.

    cheers

    Added This Also:

    <rule name="Redirect to HTTPS" enabled="true" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
    <add input="{HTTPS}" pattern="^OFF$" />
    <add input="{HTTP_USER_AGENT}" pattern="ELB-HealthChecker" negate="true" />
    <add input="{HTTP_X_FORWARDED_PROTO}" pattern="HTTPS" negate="true" />                        
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
    </rule> 
    

    The bit you want is

    <add input="{HTTP_USER_AGENT}" pattern="ELB-HealthChecker" negate="true" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use the URL Rewrite module of IIS7 to create 301
I am looking to create a 301 redirect based purely on a query string
How can you create a permanent redirect (301) in Passenger? There are posts elsewhere
I wanted to know how to create a 301 redirect from www to non-www
Create Pex test to test a DLL and hardware controlled by that DLL? I
I am trying to create an htaccess file to redirect my entire site except
I'm trying to add a simple 301 rule to the .htaccess file of a
I just got a custom handler set up to redirect with a 301 response
This will require a little setup. Trust me that this is for a good
I'm trying to create a factory_build class method for creating Redirect objects within an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.