Pass subdomain as parameter
2 posts
• Page 1 of 1
Pass subdomain as parameter
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.
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.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Pass subdomain as parameter
Hello,
Try using the following:
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
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
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests