繁体   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