2010-10-06 32 views
0

我有這種情況:的.htaccess ModRewrite的笨了停放/重定向域

  • 主機位於maindomain.com
  • othersite.com是泊來maindomain.com
  • htaccess的是用來將othersite.com的所有請求重定向到子文件夾:/ site-othersite/
  • 我想在othersite.com上使用CodeIgniter,但我不希望CodeIgniter中有一些目錄和文件位於其他站點。
  • home.php是我的CodeIgniter主頁面。

我試圖將用於停放域的通常ModRewrite與我在CodeIgniter wiki中發現的內容結合使用,但遇到了麻煩。

示例: 我不想讓othersite.com/demo/或othersite.com/robots.txt由CodeIgniter處理。我有這個:

​​

一切工作正常的CodeIgniter安裝。除了試圖讓演示/和robots.txt CodeIgniter的'ouside'不起作用。

和ModRewrite掌握有建議嗎?謝謝!

+0

我想我的混亂喜歡瞭解如何RewriteCond線的工作。所有這些都必須是真實的規則才能執行?另外,如何格式化例外(最後2個條件)。第二個條件是防止重定向循環所必需的。 – Sherri 2010-10-06 15:16:14

回答

0

想通了。它需要在兩個規則處理:

# Redirect various urls to subfolders of the format: /site-thename/ 

RewriteEngine On 

# Handle pages and directories that should not go through CodeIgniter. 
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com 
RewriteCond %{REQUEST_URI} !^/site-othersite/ 
RewriteCond %{REQUEST_URI} ^/demo/ [OR] 
RewriteCond %{REQUEST_URI} ^/robots.txt 

Rewriterule ^(.*)$ /site-othersite/$1 [L] 


# Handle CodeIgniter URLs. 
RewriteCond %{HTTP_HOST} ^(www\.)?othersite\.com 
RewriteCond %{REQUEST_URI} !^/site-othersite/ 

Rewriterule ^(.*)$ /site-othersite/home.php?/$1 [L]