0

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.

Alvaro
  • 40,778
  • 30
  • 164
  • 336

3 Answers3

1

than I can't come up with anything better than this:

########## SITE 1 
RewriteEngine on 
RewriteCond %{HTTP:Host} ^www\.website\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /mysite1/index.php?url=$1 [L,QSA] 

########## SITE 2
RewriteEngine on 
RewriteCond %{HTTP:Host} ^www\.demo\.website\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /mySecondSite/index.php?url=$1 [L,QSA] 
Andrew
  • 511
  • 3
  • 7
  • It similar to what I finally did. You can see my answer. But... why should we repeat the samem rewriteConditions? Aren't they applied to all the sites? Which separates the rewriteconds for one site and for another? – Alvaro Feb 11 '13 at 09:47
  • 1
    One condition is applied to the rule that follow it. It does not affect others. – Andrew Feb 11 '13 at 14:24
  • Thanks for the info!! :) Does it happpends the same with the RewriteEngine and the RewriteBase? Should I write them again for each group of rules? – Alvaro Feb 11 '13 at 14:37
  • 1
    No, those things identify the beginning of the config file and the prefix you're going to use for the rules below. – Andrew Feb 14 '13 at 03:44
0

In case the names of your folders are the same as the names of the sites:

RewriteEngine on 

RewriteCond %{HTTP:Host} ^www\.([^.]+)\.com$
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /%1/index.php?url=$1 [L,QSA] 
Andrew
  • 511
  • 3
  • 7
  • 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. – Alvaro Feb 08 '13 at 09:47
0

Finally I did it like this:

RewriteEngine on 
RewriteBase /

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

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

########## SITE 3 (by URL) 
RewriteCond %{HTTP_HOST} ^mysite3.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysite3.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?url=$1 [L, QSA]
Alvaro
  • 40,778
  • 30
  • 164
  • 336