TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Pts Admin
NA
12
5.3k
How to rewrite rules for these two subdomains in web.config?
May 29 2018 12:46 AM
We have two public subdomains and one main domain in IIS/Windows server.
In the server we have main site hosted at: ../mysite.com/wwwroot/
subdomain 1 hosted at ../sub1.mysite.com/wwwroot
subdomain 2 hosted at ../sub2.mysite.com/wwwroot
we want to remove www and move to https permanently. We have implemented for main domain and is working fine. Now we want to implement the same for both the subdomains. We found some solution that is working fine for one subdomain when we placed the rewrite url in its web.config file. But when we placed the same rewrite rules for subdomain 2, then subdomain2 is not working.
Not sure what is the wrong.
Here is the code we placed for subdomain 1:
<
rule
name
=
"Remove www"
stopProcessing
=
"true"
>
<
match
url
=
"(.*)"
ignoreCase
=
"true"
/>
<
conditions
logicalGrouping
=
"MatchAll"
>
<
add
input
=
"{HTTP_HOST}"
pattern
=
"^www\.(.+)$"
ignoreCase
=
"true"
/>
</
conditions
>
<
action
type
=
"Redirect"
url
=
"https://{C:1}/{R:0}"
appendQueryString
=
"true"
redirectType
=
"Permanent"
/>
</
rule
>
<
rule
name
=
"http to https"
stopProcessing
=
"true"
>
<
match
url
=
".*"
/>
<
conditions
>
<
add
input
=
"{HTTPS}"
pattern
=
"off"
ignoreCase
=
"true"
/>
</
conditions
>
<
action
type
=
"Redirect"
url
=
"https://sub1.mysite.com"
redirectType
=
"Permanent"
/>
</
rule
>
Here is the code we placed for subdomain 2:
<
rule
name
=
"Remove www"
stopProcessing
=
"true"
>
<
match
url
=
"(.*)"
ignoreCase
=
"true"
/>
<
conditions
logicalGrouping
=
"MatchAll"
>
<
add
input
=
"{HTTP_HOST}"
pattern
=
"^www\.(.+)$"
ignoreCase
=
"true"
/>
</
conditions
>
<
action
type
=
"Redirect"
url
=
"https://{C:1}/{R:0}"
appendQueryString
=
"true"
redirectType
=
"Permanent"
/>
</
rule
>
<
rule
name
=
"http to https"
stopProcessing
=
"true"
>
<
match
url
=
".*"
/>
<
conditions
>
<
add
input
=
"{HTTPS}"
pattern
=
"off"
ignoreCase
=
"true"
/>
</
conditions
>
<
action
type
=
"Redirect"
url
=
"https://sub2.mysite.com"
redirectType
=
"Permanent"
/>
</
rule
>
Reply
Answers (
4
)
unable to add lat and lng in array dynamically
Export table to excel & show 'open or save' dialog.