簡體   English   中英

解釋用於從子文件夾運行CodeIgniter的htaccess代碼

[英]Explain htaccess code used to run CodeIgniter from subfolder

我從一個子目錄運行CodeIgniter,其中mydomain.com打開我的default_controller(目前是歡迎屏幕),這個片段似乎適用於此目的,當放在我的/root/.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代碼片段嗎? 我錯過了什么至關重要的嗎? 這是在我的/ root文件夾中,它需要從URL中刪除index.php,所以我在/ root / app / build / www /子文件夾中沒有放置.htacces

我在代碼中寫了一些評論:

# 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]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM