Solved

IIS 7 URL Rewrite  Https with www to http nonwww

Posted on 2014-12-08
9
274 Views
Last Modified: 2014-12-15
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.
0
Comment
Question by:FreerTool
  • 5
  • 4
9 Comments
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
What is happening when you try to trigger that rule?  What are the logs telling you is happening?
0
 

Author Comment

by:FreerTool
Comment Utility
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
 

Author Comment

by:FreerTool
Comment Utility
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
 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:FreerTool
Comment Utility
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
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
What do you mean by "https:// google links"?  Are they going to your domain?
0
 

Author Comment

by:FreerTool
Comment Utility
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
 

Author Comment

by:FreerTool
Comment Utility
It seems to me that it has to do more with ssl.
0
 
LVL 50

Expert Comment

by:Steve Bink
Comment Utility
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Internet is a big network which is formed by connecting multiple small networks.It is a platform for all the users which are connected to it.Internet act as platform in different fields. Such as: Internet  as a collaboration platform. Internet  as…
I had to do a bit of research to find the answer to this question so I thought I'd share my results.  Due to our outdated mainframe systems, we need to downgrade IE9 to IE8 in order to stay compatible.  We also needed to downgrade Java.  In order to…
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now