Solved

IIS 7 URL Rewrite  Https with www to http nonwww

Posted on 2014-12-08
9
281 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
ID: 40489130
What is happening when you try to trigger that rule?  What are the logs telling you is happening?
0
 

Author Comment

by:FreerTool
ID: 40489137
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
ID: 40489162
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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 50

Accepted Solution

by:
Steve Bink earned 500 total points
ID: 40489207
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
 

Author Comment

by:FreerTool
ID: 40489263
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
ID: 40489280
What do you mean by "https:// google links"?  Are they going to your domain?
0
 

Author Comment

by:FreerTool
ID: 40489286
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
ID: 40489290
It seems to me that it has to do more with ssl.
0
 
LVL 50

Expert Comment

by:Steve Bink
ID: 40489392
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

773 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