0

我需要做这样的事情:

########## 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] 

问题是我只能使用一个.htaccess文件,因为我在 windows 2003 Server 上使用Helicon ISAPI_Rewrite 3 。

有没有办法将两个 .htaccess 文件合并到其中一个文件中并使它们正常工作?

我试过这个只是为了测试如果mysite没有 ,是否可以工作RewriteBase,但似乎不起作用:

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

谢谢。

4

3 回答 3

1

比我想不出比这更好的了:

########## 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] 
于 2013-02-08T17:34:12.547 回答
0

最后我这样做了:

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]
于 2013-02-11T09:45:26.447 回答
0

如果您的文件夹名称与站点名称相同:

RewriteEngine on 

RewriteCond %{HTTP:Host} ^www\.([^.]+)\.com$
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /%1/index.php?url=$1 [L,QSA] 
于 2013-02-08T00:26:12.530 回答