IIS URL Rewrite help needed

Hello,

I want to setup an IIS URL Rewrite that would do the following.

If the hostname in the url matches either:

www.sub1.domain.com
www.sub2.domain.com
www.sub3.domain.com

Redirect the URL to

sub1.domain.com
sub2.domain.com
sub3.domain.com

Essentially stripping out the "www" in these specific cases.
skbohlerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arnoldCommented:
Are these sites hosted on the same web server using the same single IP?
a rewrite under those circumstances is a resource consumer that is unneeded.
Presumably you are using host headers add the respective header to the correct site and IIs will display the correct content when the user hits www.sub1.domain.com.
If you do not want people to use www in the hostname of the subdomain, do not publish the www.sub1.domain.com record in DNS (note that some browsers when a user types in to the address bar sub1.domain.com will auto prepend the www when the http:// is not present. Those users will experience errrors)

Which IIS version (OS version where this is running)
the common
pattern match in the redirection directive
www\.(sub[0-9]+)\.domain.com/(.*)$ http://$1.domain.com/$2
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
skbohlerAuthor Commented:
Yes, I did write the article but I'm not good with the pattern recognition syntax.

We do use host headers (IIS 7)
We want to allow users to use "www".

The problem is that we use URL rewrite to switch from http to https for the domain. If we don't redirect www.sub1.domain to sub1.domain, then we have to purchase another subdomain for our SSL certificate, bind it, etc.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

skbohlerAuthor Commented:
Arnold,

Sorry for my ignorance, but what would I put in the Redirect URL properties if the condition is met?

http://{$1}.domain.com/{$2}
0
arnoldCommented:
not sure what article you mean,
the pattern match
http://www\/(sub[0-9]+)\.domain\.com/(.*)$ https://$1.domain.com/$2
will do what you want.

I am uncertain whether your version can handle the redirect config in web.config.
do all www.sub*.domain.com end up on the same

IMHO, you can still achieve the same thing given you already have redirect to secure site.
the rule presumably does not care which URL you are requesting via http:// any request will be redirected to https://subx.domain.com
So it will not pose a certificate error issue.

There is no avoiding the certificate issue when a user enters https://www.sub1.domain.com sine the error will show long before IIS sees the actual HTTP request.  Exchange of certificates to establish the secure connection happens first and the error will be displayed to the user before to approve in order for the secure connection to be established.
0
skbohlerAuthor Commented:
I'm doing it all through the IIS interface.

The redirect http://{C:1}.domain.com/{R:0} seems to work. Thanks!
0
arnoldCommented:
Try the pattern I posted on a subset test site.

The following link covers the GUI approach after you follow the link, "Creating rewrite rules for the URL Rewrite Module.
https://technet.microsoft.com/en-us/library/ee215218%28v=ws.10%29.aspx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.