This forum has been moved here:
Helicon Tech Community Forum

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  HelpHelp   RegisterRegister  LoginLogin
ISAPI_Rewrite 2.x (Forum Locked Forum Locked)
 Helicon Tech : ISAPI_Rewrite 2.x
Subject Topic: help with rewrite multi-site
Author
Message |
rezdragon
Newbie


Joined: 01 October 2008
Location: United States
Posts: 7
Posted: 14 December 2010 at 2:57pm

ok here is the deal i have 3 sites using 3 different ip's i was under the impression that i needed to have different ips point to the 3 different sites. But i'd like to consolidate down to just 1 ip with like host headers

here is my current rules, any help would be appreciated

[ISAPI_Rewrite]
#wordpress rewrite for admin
RewriteRule /wordpress.* $0 [I,L]

# Defend your computer from some worm attacks
RewriteRule .*(?:global.asa|default\.ida|root\.exe|\.\.).* . [F,I,O]

RewriteCond Host: www\.(.*\.autsp\.com)
RewriteRule (.*) http\://$1$2 [I,RP]

    RewriteCond Host: www\.(.*\.boatsp\.com)
    RewriteRule (.*) http\://$1$2 [I,RP]

            RewriteCond Host: www\.(.*\.truksp\.com)
            RewriteRule (.*) http\://$1$2 [I,RP]

# Convert http://autsp.com to http://www.autsp.com/
RewriteCond Host: ^autsp.com
RewriteRule (.*) http\://www\.autsp.com$1 [I,RP]


    # Convert http://autsp.com to http://www.boatsp.com/
    RewriteCond Host: ^boatsp.com
    RewriteRule (.*) http\://www\.boatsp.com$1 [I,RP]

            # Convert http://truksp.com to http://www.truksp.com/
            RewriteCond Host: ^truksp.com
            RewriteRule (.*) http\://www\.truksp.com$1 [I,RP]


# Assuming we have limited number of shared folders.
# We will execute them accordingly regardless of the subdomain.
# autsp: http://sub1.autsp.com/img/logo.jpg -> /img/logo.jpg
# autsp: http://www.autsp.com/img/logo.jpg -> /img/logo.jpg
RewriteRule (/css/.*) $1 [I,O,L]
RewriteRule (/js/.*) $1 [I,O,L]
RewriteRule (/img/.*) $1 [I,O,L]


    # Assuming we have limited number of shared folders.
    # We will execute them accordingly regardless of the subdomain.
    # autsp: http://sub1.boatsp.com/img/logo.jpg -> /img/logo.jpg
    # autsp: http://www.boatsp.com/img/logo.jpg -> /img/logo.jpg
    RewriteRule (/css/.*) $1 [I,O,L]
    RewriteRule (/js/.*) $1 [I,O,L]
    RewriteRule (/img/.*) $1 [I,O,L]


            # Assuming we have limited number of shared folders.
            # We will execute them accordingly regardless of the subdomain.
            # truksp: http://sub1.truksp.com/img/logo.jpg -> /img/logo.jpg
            # truksp: http://www.truksp.com/img/logo.jpg -> /img/logo.jpg
            RewriteRule (/css/.*) $1 [I,O,L]
            RewriteRule (/js/.*) $1 [I,O,L]
            RewriteRule (/img/.*) $1 [I,O,L]


#Redirect all other subdirectories not matching
#to the list above as subdomains
#autsp: www.autsp.com\sub1 -> sub1.autsp.com
RewriteCond Host: www\.highspeed\.com
RewriteRule /(\w*)/(.*) http\://$1\.autsp\.com$2 [I,RP]


    #Redirect all other subdirectories not matching
    #to the list above as subdomains
    #autsp: www.boatsp.com\sub1 -> sub1.boatsp.com
    RewriteCond Host: www\.highspeed\.com
    RewriteRule /(\w*)/(.*) http\://$1\.boatsp\.com$2 [I,RP]


            #Redirect all other subdirectories not matching
            #to the list above as subdomains
            #autsp: www.truksp.com\sub1 -> sub1.truksp.com
            RewriteCond Host: www\.highspeed\.com
            RewriteRule /(\w*)/(.*) http\://$1\.truksp\.com$2 [I,RP]



# If the web site starts with www then point the file to the root folder
# If you specifically created a folder /www/ then you can comment out this section.
RewriteCond Host: (?:www\.)autsp.com
RewriteRule (.*) $1 [I,O,L]


    # If the web site starts with www then point the file to the root folder
    # If you specifically created a folder /www/ then you can comment out this section.
    RewriteCond Host: (?:www\.)boatsp.com
    RewriteRule (.*) $1 [I,O,L]


            # If the web site starts with www then point the file to the root folder
            # If you specifically created a folder /www/ then you can comment out this section.
            RewriteCond Host: (?:www\.)truksp.com
            RewriteRule (.*) $1 [I,O,L]


# Any web site starts other than www will be re-mapped to /<subdomain>/
# autsp: http://sub1.autsp.com/default.asp -> /sub1/default.asp
# Note: if the folder does not exists, then the user will get a 404 error automatically.
RewriteCond Host: (.*)\.autsp.com
RewriteRule (.*) /$1$2 [I,O,L]


    # Any web site starts other than www will be re-mapped to /<subdomain>/
    # autsp: http://sub1.boatsp.com/default.asp -> /sub1/default.asp
    # Note: if the folder does not exists, then the user will get a 404 error automatically.
    RewriteCond Host: (.*)\.boatsp.com
    RewriteRule (.*) /$1$2 [I,O,L]

            # Any web site starts other than www will be re-mapped to /<subdomain>/
            # autsp: http://sub1.truksp.com/default.asp -> /sub1/default.asp
            # Note: if the folder does not exists, then the user will get a 404 error automatically.
            RewriteCond Host: (.*)\.truksp.com
            RewriteRule (.*) /$1$2 [I,O,L]

#Emulate site1
RewriteCond Host: (?:www\.)?autsp\.com
RewriteRule (.*)   /autsp$1 [I,L]

#Emulate site2
RewriteCond Host: (?:www\.)?truksp\.com
RewriteRule (.*)   /truksp$1 [I,L]

#Emulate site1
RewriteCond Host: (?:www\.)?boatsp\.com
RewriteRule (.*)   /boatsp$1 [I,L]


#Fix missing slash char on folders
#This has to be at the end because if invalid dir exists,
#we should show 404 first
RewriteCond Host: (.*)

Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 15 December 2010 at 5:54am

Well you seem to be doing everything correctly, except that you actually need to put RewriteCond Host: directive before EACH rule, like you
did at the beginning of the config.

__________________
Regards,
Anton
Back to Top
 
rezdragon
Newbie


Joined: 01 October 2008
Location: United States
Posts: 7
Posted: 15 December 2010 at 6:32am

yes but for some reason the 3 different sites do not work as 3 sites since i cannot have host headers to allow them to use 1 ip instead i have to waste 3 ips, 1 for each site
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 15 December 2010 at 8:41am

I guess you should simply set up this in IIS...

__________________
Regards,
Anton
Back to Top
 
rezdragon
Newbie


Joined: 01 October 2008
Location: United States
Posts: 7
Posted: 15 December 2010 at 8:48am

yes but the problem with this, is that each one of those sites has 30+ folders inside that work as subdomains. just by creating the folder
Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 16 December 2010 at 5:25am

Ok, there are two solutions for this:

1. set the following bindings in IIS:

host header1 - ip1 - site1
host header2 - ip1 - site2
host header3 - ip1 - site3

In this case there no need to emulate host headers in ISAPI_Rewrite as they will be set directly in IIS.

2. have the following binding in IIS (to catch requests from all sites)

host header=* - ip1 - site0

And on site0 have Emulate host headers rules for ISAPI_Rewrite.

__________________
Regards,
Anton
Back to Top
 
rezdragon
Newbie


Joined: 01 October 2008
Location: United States
Posts: 7
Posted: 16 December 2010 at 9:58am

ok we have done that, we put in all the headers in IIS and we get

Bad Request (Invalid Hostname)

i then tried taking out the headers and using rewrite with this
[ISAPI_Rewrite]

#Fix missing slash char on folders
RewriteCond Host: (.*)
RewriteRule ([^.?]+[^.?/]) http\://$1$2/ [I,R]

#Emulate site1
RewriteCond Host: (?:www\.)?site1\.com
RewriteRule (.*) /site1$1 [I,L]

#Emulate site2
RewriteCond Host: (?:www\.)?site2\.com
RewriteRule (.*) /site2$1 [I,L]
i still get

Bad Request (Invalid Hostname)


Back to Top
 
Anton
Admin Group


Joined: 30 January 2007
Location: Ukraine
Posts: 10519
Posted: 17 December 2010 at 3:19am

So you have set up the IIS to catch all host headers, right?
And where did you put the above ISAPI_Rewrite rules? In global httpd.ini?

__________________
Regards,
Anton
Back to Top
 

Sorry, you can NOT post a reply.
This forum has been locked by a forum administrator.

Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum