2010-10-22 27 views
0

我很可能很簡單的mod_rewrite taks掙扎。mod_rewrite不同的URI到一個位置

這是目錄結構,我有:

  • 根\
    • 翻譯\
      • EN \(包含文件,2級深各子文件夾)
      • fr \(包含文件,2級深各子文件夾)

我想要做的是指向各種動態創建的URL到這些具體的位置,而在地址欄中更改URL。

例如:

mydomain.com/one/ 
mydomain.com/two/ 
mydomain.com/three/ 

- >所有會讀內容從/root/translations/en/index.php

mydomain.com/one/sub1/sub2/ 
mydomain.com/two/sub1/sub2/ 
mydomain.com/three/sub1/sub2/ 

- >會讀從/根含量/ translations/en/sub1/sub2/index.php

mydomain.com/onefr/ 
mydomain.com/twofr/ 
mydomain.com/threefr/ 

- >所有從/root/translations/fr/index.php

mydomain.com/onefr/sub1/sub2/ 
mydomain.com/twofr/sub1/sub2/ 
mydomain.com/threefr/sub1/sub2/ 

會讀的內容 - >將宣讀/root/translations/fr/sub1/sub2/index.php內容

我想是這樣的:

RewriteCond %{REQUEST_URI} !\.css$ [NC] 
RewriteRule ^/(one|two|three)/$ /_translations/en/ [L] 

RewriteCond %{REQUEST_URI} !\.css$ [NC] 
RewriteRule ^/(onefr|twofr|threefr)/$ /_translations/fr/ [L] 

,雖然它爲默認的重定向(例如, mydomain.com/one/)我想去的那一刻更深它拋出404

任何線索?

回答

0

嘗試下列規則:

RewriteCond %{REQUEST_FILENAME} -f 
RewriteRule^- [L] 

RewriteRule ^/(one|two|three)/(.*) /_translations/en/$2 [L] 

RewriteRule ^/(one|two|three)fr/(.*) /_translations/fr/$2 [L] 

的第一條規則將停止,可以映射到一個現有的文件被任何以下規則被改寫的任何請求。另外兩條規則適用於你描述的兩種情況。

+0

這正是我所需要的!謝謝! – criography 2010-10-22 16:55:14