Search code examples
iiswindows-server-2008iis-7.5isapiisapi-rewrite

ISAPI_Rewrite 3.0 ... Noob ... how to get started? just installed


just installed v3 lite to try it out before getting full version.

i got the follwing in .htaccess file in the root folder of the .net web app

RewriteEngine On
RewriteCond %{HTTPS} (on)?
RewriteCond %{HTTP_HOST} ^zzzz-wildcard\.domain\.com
RewriteRule ^(.*)$ http://domain.com/zzzz-wildcard$1 [R]

problem is it doesn't do anything. i got the wildcard set up on iis so that

test.domain.com is served just as domain.com would be. What i want to achieve is to serve any sub-domain user1.domain.com as domain.com/zzzz-wildcard

from what i got so far even explicity supplying zzzz-wildcard.domain.com still serves the default.aspx of the domain.com instead of domain.com/zzzz-wildcard/default.aspx

please help. i have never worked with isapi rewrite so i have no clue how to go about this.... right now as it stand it doesn't really do anything. can't say i'm good with regular expressions either :(

When opening ISAPI_Rewrite Manager and selecting my domain.com from the list of iis websites it says No properties available for this node.

******** EDIT ********

after some more looking around i found out that lite version doesn't support .htaccess so only httpd.conf file that works globally. So anyway i modified the httpd.conf file instead and it now works..

however it just redirects zzzz-wildcard.domain.com to domain.com/zzzz-wildcard

Is there a way to keep the url intact and not redirect? but still serve the pages from domain.com/zzzz-wildcard ?


Solution

  • finally solved after looking around other answers on stackoverflow

    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
    RewriteCond %{HTTP_HOST} ^(.*?)\.domain\.com$ [NC]
    RewriteRule (.*) /zzzz-wildcard/%{REQUEST_URI} [NC]