For the HTTP_HOST it does not look at the http:// part just yet the actual domain name.
How does the rule fail? Doesn't seem to do anything? Redirect to the wrong place?
And make sure you are using a new browsers /cleared all cache as befire you have tried a rule with a perm redirect which will stay for all time broken in your browser.
Does this have something to do with how my DNS A records are setup? When I ping domain.com AND www.domain.com, they both resolve to the correct public IP.
I put the above script in both the URL Rewrites for 'Default Web Site' and for the URL Rewrites listed when I click on the IIS server itself.
Note my actual www.domain.com server is an internal apache server that is routed to a server farm that contains the apache server, if that makes any difference?
Additionally, the test patterns on this rule match fine. And on the ARR server itself,
domain.com resolves to the internal IP of the web server, and the website is properly shown.
23 Posts
Prepend www to incoming domain.com is not working
Sep 07, 2019 11:11 AM|JefffRozar|LINK
I setup a URL Rewrite Rule that redirects any incoming domain.com Pattern to redirect to https://www.domain.com/{R:0}
I put this in ARR 3.0 in both the URL Rewrite for the ARR Server's URL Rewrite option and also in the 'Default Web Site' URL Rewrite option.
Match URL is: WIldcards, *
Condition is: {HTTP_HOST}, Matches the Pattern, domain.com
Redirect (Permanent) goes to: https://www.domain.com/{R:0}
Neither rule is working.
Where else can I look or how can I fix this?
4042 Posts
Re: Prepend www to incoming domain.com is not working
Sep 09, 2019 07:30 AM|Yuk Ding|LINK
Hi JefffRozar,
Please try this rule, it is working perfectly for me. Just ensure you are setting this rule under the website with domain "domain.com".
Best Regards,
Jokies Ding
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
23 Posts
Re: Prepend www to incoming domain.com is not working
Sep 09, 2019 11:38 PM|JefffRozar|LINK
Works perfect! Thank you! I did it within the IIS interface: http://imgsafe.org/image/6e22460a95
I made it the first rule in my list.
4042 Posts
Re: Prepend www to incoming domain.com is not working
Sep 10, 2019 02:32 AM|Yuk Ding|LINK
Hi JefffRozar,
I'm so glad that the problem was resolved with my rule. It is so appreciated if you could mark the reply as answer.
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
23 Posts
Re: Prepend www to incoming domain.com is not working
Sep 15, 2019 03:09 PM|JefffRozar|LINK
Problem...when a user types in domain.com, in IE, for example, it prepends http:// to it, so the string is http://domain.com.
This does not get prepended with www.
I put in an {HTTP_HOST} match as http://domain.com but it still does not work.
The wildcard pattern does not match: http://imgsafe.org/image/f69953f242
And the conditions pattern doesn't match either: http://imgsafe.org/image/f6a1459048
Why?
Also, does iisreset need to be run when a rule is changed?
4042 Posts
Re: Prepend www to incoming domain.com is not working
Sep 19, 2019 05:40 AM|Yuk Ding|LINK
Hi JefffRozar,
Because you are using URL regex expression under wildcards. Please change wildcard to regular expression and try again.
Best Regards,
Jokies Ding
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
23 Posts
Re: Prepend www to incoming domain.com is not working
Sep 20, 2019 12:56 PM|JefffRozar|LINK
I don't have it set to Regular Expressions. Mine is set to Wildcards. Not sure where you got that image.
Can you look at my screenshots? Wildcard and Conditional are not matching the Test Pattern either.
5495 Posts
MVP
Moderator
Re: Prepend www to incoming domain.com is not working
Sep 20, 2019 01:43 PM|Rovastar|LINK
The solution posted is for regular expressions (that is generally how we do rewrite rules)
Wildcards use a different syntax.
So to fix it try it in regular expressions.
https://www.leansentry.com/
4042 Posts
Re: Prepend www to incoming domain.com is not working
Sep 20, 2019 05:40 PM|Yuk Ding|LINK
Hi JefffRozar,
I mean you should change using:wildcard to using:regular expression. (.*) and ^ $ is regex expression format instead of wildcard expression format.
So if you change the expression type. the rule should start working.
Best Regards,
Jokies Ding
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
23 Posts
Re: Prepend www to incoming domain.com is not working
Sep 24, 2019 05:19 PM|JefffRozar|LINK
So I changed to:
Still doesn't work when I put in http://domain.com
When I edit the condition pattern of ^domain.com$, the test pattern fails when I put in http://domain.com
But if the pattern is just domain.com, the test pattern of http://domain.com succeeds, but the rule still fails.
5495 Posts
MVP
Moderator
Re: Prepend www to incoming domain.com is not working
Sep 25, 2019 12:14 PM|Rovastar|LINK
For the HTTP_HOST it does not look at the http:// part just yet the actual domain name.
How does the rule fail? Doesn't seem to do anything? Redirect to the wrong place?
And make sure you are using a new browsers /cleared all cache as befire you have tried a rule with a perm redirect which will stay for all time broken in your browser.
https://www.leansentry.com/
23 Posts
Re: Prepend www to incoming domain.com is not working
Sep 25, 2019 03:05 PM|JefffRozar|LINK
It fails with a 404 when I put this exact string in a browser on a brand new VM I brought up using IE: http://domain.com
As in this example shows, the test pattern for the condition fails: http://imgsafe.org/image/c92502ddd0
4042 Posts
Re: Prepend www to incoming domain.com is not working
Sep 27, 2019 09:13 AM|Yuk Ding|LINK
Hi JefffRozar,
Before you apply URL rewrite, please ensure both domain.com and www.domain.com can be accessed at the same time.
Then you need to clean browser cache to refresh the redirect cache.
This rule is working on my side
When you access domain.com, IIS return 307 response and client get redirected to https://www.domain.com.
So you need to check whether URL has been changed and whether https://www.domain.com is available currently.
And the value of {HTTP_HOST} is domain.com not https://domain.com. So you shouldn't input https://domain.com in the pattern test.
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue.
23 Posts
Re: Prepend www to incoming domain.com is not working
Oct 01, 2019 01:13 PM|JefffRozar|LINK
Not sure what you mean by ensure both domain.com and www.domain.com can be accessed at the same time?
https://www.domain.com is available and working fine. And I have a redirect of http -> https and that is also working fine.
But when I do http://domain.com, I also get a 404.
Does this have something to do with how my DNS A records are setup? When I ping domain.com AND www.domain.com, they both resolve to the correct public IP.
23 Posts
Re: Prepend www to incoming domain.com is not working
Dec 15, 2020 12:32 PM|JefffRozar|LINK
Hi, I'm revisiting this again.
My IIS has a few sites:
Default Web Site
register.domain.com
support.domain.com
I put the above script in both the URL Rewrites for 'Default Web Site' and for the URL Rewrites listed when I click on the IIS server itself.
Note my actual www.domain.com server is an internal apache server that is routed to a server farm that contains the apache server, if that makes any difference?
Additionally, the test patterns on this rule match fine. And on the ARR server itself, domain.com resolves to the internal IP of the web server, and the website is properly shown.