rewrite subdomain to dynamic folder

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 21
Joined: 12 Apr 2013, 08:19

rewrite subdomain to dynamic folder

10 May 2016, 08:43

Hi,

I want to rewrite mysubdomain and all pages/folders from this subdomain to following way:

* mysub.mydomain.com -> mydomain.com/xrep/mysub/
* mysub.mydomain.com/anyfolders/anypages.html -> mydomain.com/xrep/mysub/anyfolders/anypages.html

I got a rule that doesn't work.

RewriteCond %{HTTP_HOST} !^www.mydomain.com
RewriteCond %{HTTP_HOST} ^([^.]+).mydomain.com
RewriteRule ^$ /xrep/%1 [NC]

It write me : Bad Request - Request Too Long

Can you help?

Thanks in advance.

User avatar
Posts: 402
Joined: 06 Mar 2012, 11:59

Re: rewrite subdomain to dynamic folder

11 May 2016, 08:23

Hello.

First of all I need to clarify what you mean by rewrite here. Term "rewrite" may only apply when a request is internally transferred to another page within one web site. According to your specs I suppose request needs to cross web site's boundaries. In this situation we usually talk about redirect or proxy. Or maybe both mysub.mydomain.com and www.mydomain.com bindings are set up to the same IIS web site? Then rewrite may take place as request will stay on one web site.
And what is your requirement about what user should see in address bar when he visits mysub.mydomain.com/anyfolders/anypages.html? Should he see original address or see mydomain.com/xrep/mysub/anyfolders/anypages.html (then it is redirect)?

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 14 guests