IIS 7 URL Rewrite Https with www to http nonwww

I have been struggling all day to get some old links to do a 301 redirect to my new links.

I am trying to get https://www.freertool.com/store/en/freer-naams-alb081m-2 to redirect to http://freertool.com/freer-naams-alb081m-2

<rule name="RedirectWWW" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^freertool\.com$" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://freertool.com/{R:1}" />
                </rule>
                <rule name="RemoveDirectory" enabled="true" stopProcessing="true">
                    <match url="^store/en/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTP_HOST}" pattern="^freertool\.com$" negate="true" />
                    </conditions>
                    <action type="Redirect" url="http://freertool.com/{R:1}" redirectType="Permanent" />
                </rule>

Open in new window


What am I missing, I have been banging my head all day on this.
FreerToolAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Steve BinkConnect With a Mentor Commented:
On rules 1 and 4 ("Store Redirect Store www" and "Store Redirect www and en"), your match URL contains the hostname, which should not be present.  If you need to test for the host, use a <conditions> section.

Since you also want to redirect based on SSL status, you'll likely need the {HTTPS} server variable.  You can see a full list of the server variables available at http://msdn.microsoft.com/en-us/library/ms524602(v=vs.90).aspx.

Finally, I'm not entirely sure how IIS handles directory context in the rewrite module.  In Apache, the beginning slash on a URL may or may not be present, depending on the context of the rule.  I normally account for this by modifying the regex to include an optional initial slash:
<match url="^/?store(.*)" />

Open in new window

If you encounter any further issues, turn on your tracing, and post the trace log for a single attempt to trigger the problem rule.
0
 
Steve BinkCommented:
What is happening when you try to trigger that rule?  What are the logs telling you is happening?
0
 
FreerToolAuthor Commented:
I updated  my rules and can get every redirect to work except for https://www.freertool.com/store/en  links

for example  https://www.freertool.com/store/en/freer-naams-alb081 wont work but if i remove the S on HTTPS it goes through.

 I am just missing a step i believe should i create another rule to handle Https prior to loading the other rules?

    <rules>
                <clear />
                <rule name="Store Redirect Store www" stopProcessing="true">
                    <match url="^www.freertool.com/store(.*)" />
                    negate="true" />
                    <action type="Redirect" url="http://freertool.com{R:1}" />
                </rule>
                <rule name="Store Redirect EN" enabled="true" stopProcessing="true">
                    <match url="^en(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Redirect" url="http://freertool.com{R:1}" />
                </rule>
                <rule name="Store Redirect Store" stopProcessing="true">
                    <match url="^store(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
                    <action type="Redirect" url="http://freertool.com{R:1}" />
                </rule>
                <rule name="Store Redirect www and en" enabled="true">
                    <match url="^www.freertool.com/store/en/(.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    </conditions>
                    <action type="Rewrite" url="http://freertool.com{R:1}" />
                </rule>            
            </rules>
0
Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

 
FreerToolAuthor Commented:
I can look at this 2 ways if i remove the www from link it redirects or if i remove the s on https it redirects.  I am just trying to figure out the condition combo to get this to work correctly
0
 
FreerToolAuthor Commented:
I turned on tracing and now i find out that all my https:// google links aren't even getting served on the server, so i cant trace something that's not getting there any ideas or should i just remove them one by one from google webmaster?
0
 
Steve BinkCommented:
What do you mean by "https:// google links"?  Are they going to your domain?
0
 
FreerToolAuthor Commented:
I have tracing turned on and if you click on the link for this https://www.freertool.com/store/en/freer-naams-alb081

the trace is not appearing in my log.  Does that make sense?
0
 
FreerToolAuthor Commented:
It seems to me that it has to do more with ssl.
0
 
Steve BinkCommented:
Can you verify that your server is fielding that request at all?  When you ping freertool.com, does the IP match the IP of your server?  Is the site (with and without SSL) configured to listen on that IP?  Do you see any hits in the access/activity log?
0
All Courses

From novice to tech pro — start learning today.