2009-12-17 61 views
1

我試圖讓「TRAC」目錄和它的所有子目錄是通過URL訪問http://www.domain.com/trac/代碼點火器子目錄問題

我與codeginiter框架的工作和我的目錄結構看起來像

.htaccess 
index.php 
system 
trac 

我可以很好地訪問abov網址,但問題是trac子目錄中包含的腳本和其他文件,例如:trac/chrome/common/css/trac.css不可訪問,404。這是我的.htaccess代碼。請幫忙。

RewriteEngine On 
RewriteRule ^$ index.php [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
RewriteCond $1 !^trac/ 
RewriteRule ^trac/(.*) /trac/$1 

回答

0

如果您刪除最後兩行,它應該工作。

RewriteCond %{REQUEST_FILENAME} !-f檢查以確保您沒有請求文件。如果你是,這個條件失敗,規則RewriteRule ^(.*)$ index.php?/$1 [L]永遠不會執行。

1

重寫規則,以便執行......所以試試這個

RewriteCond %{REQUEST_URI} !^/trac/ 
RewriteCond $1 !(index\.php/) 
RewriteRule ^(.*)$ index.php?/$1 [L] 

說明:

if the uri DOES NOT start with trac 
if the uri IS NOT index.php 
rewrite url as index.php?/{rest of the url} 
2

你甚至都不需要提及/ TRAC /在你的.htaccess。這完全是點的

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

你正在設置兩個「重寫條件」。第一個說:「只要請求不是文件。」第二個說「或者只要請求不是目錄。」

然後

RewriteRule ^(.*)$ index.php?/$1 [L] 

發送其他一切的index.php,其中CI接管。和公正的記錄,我的全部的.htaccess我在每一個項目中使用:

Options +FollowSymLinks 

RewriteEngine On 
RewriteBase/

RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

如果你感到困惑的RewriteCond %{REQUEST_URL} ^system.*線,它只存在使任何瀏覽器請求到/系統/文件夾始終路由到index.php,因此被忽略。