2014-07-22 38 views
1

我從子目錄運行CodeIgniter,其中mydomain.com打開我的default_controller(當前是歡迎屏幕),並且此代碼段似乎適用於此目的,當放置在我的/ root/.htaccess,但即使引用它仍然對我來說很神奇。解釋用於從子文件夾運行CodeIgniter的htaccess代碼

Options +FollowSymLinks 
RewriteEngine On 
RewriteBase /app/main/build/www 

RewriteRule ^$ index.php [L] 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico) 

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

有人可以解釋這個htaccess的代碼段在低級行?我錯過了任何重要的東西?這是在我的/根文件夾,它需要擺脫index.php出url,所以我沒有在我的/ root/app/build/www /子文件夾沒有放置.htacces

回答

3

我寫了一些評論在代碼:

# Tell the server to follow symbolic links 
Options +FollowSymLinks 

# Enable mod-rewrite 
RewriteEngine On 

# Strip /app/main/build/www from the string to be tested by regex 
RewriteBase /app/main/build/www 

# If the url empty, redirect to index.php (^ is start of line, $ is end of line) 
RewriteRule ^$ index.php [L] 

# If the url is not an existing directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# And if the url is not an existing fie 
RewriteCond %{REQUEST_FILENAME} !-f 
# And if the file does not start with index.php or the other two... 
RewriteCond $1 !^(index\.php|robots\.txt|favicon\.ico) 
# Then rewrite the url to index.php?file, and make this the last rule 
# Note that (.*) captures every character of the file name to Group 1, and that 
# $1 is a reference to that capture (used once in the cond, once in the rule) 
RewriteRule ^(.*)$ index.php?/$1 [L] 
+0

這是完美的,感謝幫助了很多。也可以幫助我應用我一直在看的其他片段。乾杯! :) – mtpultz

+0

非常歡迎,很高興幫助! :) – zx81