我正在设置我的第一个个人codeigniter项目,我的.htaccess文件就是这样:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /madrigal/
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
我已将config.php文件设置为$ config ['index_page'] ='';和$ config ['uri_protocol'] ='REQUEST_URI';但是当我转到我的控制器/ admin /时,除非我在URL的末尾输入“/ index”,否则不会运行索引。我的htaccess文件不允许这样做吗?
感谢您的帮助
答案 0 :(得分:1)
答案 1 :(得分:0)
您可以使用带有一些简单规则的.htaccess文件轻松删除此index.php。
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|img|js)
RewriteRule ^(.*)$ /index.php/$1 [L]
在上面的示例中,除index.php,images和robots.txt之外的任何HTTP请求都被视为对index.php文件的请求。您可以阅读文档here
$config['index_page']
是要调用的默认页面的配置,而不是用于删除URI中的index.php