Solved

IIS 7 URL Rewrite  Https with www to http nonwww

Posted on 2014-12-08
9
298 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 51

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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 
LVL 51

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 51

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 51

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

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

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

Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
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…
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 +…

705 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