Quantcast
Channel: URL Rewrite Module
Viewing all articles
Browse latest Browse all 2482

Rewrite to enforce www but allow subdomains

$
0
0

I currently have this in my config which enforces WWW and HTTPS:

<rewrite><rules><rule name="Redirect to WWW" stopProcessing="true"><match url="(.*)" /><conditions><add input="{HTTP_HOST}" pattern="^www\." negate="true" /></conditions><action type="Redirect" url="http://www.{HTTP_HOST}{HTTP_URL}" appendQueryString="false" redirectType="Permanent" /></rule><rule name="Redirect to HTTPS"><match url="(.*)" /><conditions><add input="{SERVER_PORT_SECURE}" pattern="^1$" /></conditions><action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" /></rule></rules></rewrite>

What I would like to do is continue enforcing the "WWW" rule but, I'd like to add a subdomain (say "dev.sitename.com").

In this way, "sitename.com" would always go to "www.sitename.com" but "dev.sitename.com" would stay at "dev.sitename.com" - with the above rule in place, it redirects to "www.dev.sitename.com".

I must admit my understanding of this is a bit rudimentary but I've read through the following posts and have been unable to come up with the solution on my own:

http://ruslany.net/2009/04/10-url-rewriting-tips-and-tricks/

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/url-rewrite-module-configuration-reference

https://madskristensen.net/post/url-rewrite-and-the-www-subdomain

Thanks for your assistance!


Viewing all articles
Browse latest Browse all 2482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>