Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would need to do something like this:

########## SITE 1 
RewriteEngine on 
RewriteBase /mysite1  
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] 

########## SITE 2
RewriteEngine on 
RewriteBase /mySecondSite   
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA] 

The problem is that i can only use one .htaccess file as I am using Helicon ISAPI_Rewrite 3 over windows 2003 Server.

Is there a way to combine both .htaccess files in just one of them and making them work properly?

I have tried this just to test if mysite would work without the RewriteBase, but seems not to work:

RewriteEngine on 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^mysite1/(.*)$ index.php?url=$1 [L,QSA] 

Thanks.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

Try this

RewriteEngine on 
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^mysite1/(.*)$ mysite1/index.php?url=$1 [L,QSA] 
RewriteRule ^mysite2/(.*)$ mysite2/index.php?url=$1 [L,QSA] 
share|improve this answer
    
Thanks, it almost works but if i use it as you did, the CSSs of the second site (mysite2) doesn't load. If i invert the order of the rules, then it happends only with mysite1. Therefor, i guess it still being something wrong in the rules as depending on the order it acts in one way or another. What could it be?? –  Steve Feb 8 '13 at 9:43
    
Ok. It seems that the first two RewriteCond about files or folders are not being applied to the second RewriteRule. I've solved it adding again the 2 RewriteCond after the first RewriteRule. It works well now but... is it correct? Why is it happening? Thanks. –  Steve Feb 8 '13 at 10:12
add comment

Assuming your directory names correspond with the domain names e.g. www.mySite.com has it's files located in directory /mySite/ and www.myOtherSite.com has it's files in /myOtherSite/ then you could try the following:

[ISAPI_Rewrite]
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST}        ^(www\.)?([^.]*)\.com$
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .*    /%2/index.php?url=%{REQUEST_URI} [L,QSA] 
share|improve this answer
    
One of the sites has a domain (www.website.com), the other is just a subfolder inside a subdomain (www.demo.website.com/website2/) I dont know if it would be so simple in this case. –  Steve Feb 8 '13 at 9:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.