2010-11-26 58 views
0

我用這對我重寫幫助創建URI重寫使用重寫規則

RewriteRule ^site/(.*) index.php?rewrite=$1 [L] 
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase] 

我開始逐步本網站成爲一個僞MVC體系和真正需要上述讀

1. If the directory is NOT ^site/public/* OR ^site/assets/* or (etc) then re-write the url as index.php?rewrite=$1 (I'm basically trying to replicate the first rule above for all cases except a couple). 
2. ALSO, go ahead and rewrite all .xml pages to be changed to .php 

回答

1

您可以對第一條規則進行調整,以防止它在這些特定情況下適用:

# Only apply the rule when the captured section does not start 
# with public/ or assets/ 
RewriteCond $1 !^(public|assets)/ 
RewriteRule ^site/(.*) index.php?rewrite=$1 [L] 

看起來像是第二條規則已經做到了你所期望的,所以如果不是這種情況,你需要詳細說明問題在哪裏。