Pass subdomain as parameter

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 1
Joined: 23 May 2012, 09:58

Pass subdomain as parameter

24 May 2012, 09:56

I'm new to ISAPI_Rewrite & regular expressions. I'm in need of a rewrite rule that will remove the subdomain and pass it as a parameter. For example:

mysubdomain.mydomain.com

should become

mydomain.com/Landing.aspx?ID=mysubdomain

Any help would be appreciated.


Note: I'm using the full version of ISAPI_Rewrite so this rule will be at the site-level.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Pass subdomain as parameter

24 May 2012, 10:18

Hello,

Try using the following:

Code: Select all
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP:Host} !^www\.mydomain\.com$
RewriteCond %{HTTP:Host} ^([^.]+)\.mydomain\.com$
RewriteRule ^$ /Landing.aspx?ID=%1 [NC,L]


You did not specify if you want a 301-redirect or a rewrite,so in case you want it to be redirect, use [NC,R=301,L] instead of [NC,L].

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 3 guests