2010-09-10 33 views
0

我在同一個域中運行兩個站點(相同的網站,但在WordPress的舊的和新的自定義).htaccesss兩個網站

我需要做的:

如果客戶索要存在的文件,那麼他就可以看出來:(這工作)

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

任何其他請求轉向到index.php

RewriteRule . /index.php [L] 

好的...但是,如果你問/(www.site.com),你將被重定向到www.site.com/site2而沒有進入谷底index.php

我該怎麼做到這一點? 僞代碼(英語不好,對不起)

if(request == "/" || request == www.site.com) { 
    redirect site2/ 
} else if(ask_for_a_file_that_exists) { 
    server file 
} else { 
    use old index.php 
} 
+0

你想執行內部或外部重定向?另外,新站點是否在'site2'目錄的'.htaccess'文件中有自己的'mod_rewrite'規則? – 2010-09-10 07:39:03

回答

0

像這樣的東西應該工作:

# Check if the request was for the root, and if so, redirect 
# internally to the site2 folder 
RewriteRule ^$ /site2/ [L] 

# Otherwise, let the existing site take care of the rest 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L]