我正在尝试配置CodeIgniter并从URL中删除index.php
。我将.htaccess
文件放在了应用程序文件夹中,并尝试了用户发布的各种代码。但它没有用,index.php
仍在那里。最初该文件位于config
文件夹中。任何人都可以帮我这个吗?
欢迎所有建议...... 提前谢谢......
答案 0 :(得分:1)
您应该将.htaccess文件放在根目录下而不是在应用程序文件夹中。
在.htaccess文件中保留以下行并将其保存在根目录中。它应该使用和不使用index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
答案 1 :(得分:0)
转到application / config / config.php并编辑下一步:
$config['index_page'] = 'index.php';
$config['uri_protocol'] = 'AUTO';
为:
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
如果这不起作用,请发布.htaccess文件内容。
答案 2 :(得分:0)
您应该编辑的唯一.htaccess是放在您网站根目录中的那个(或者您的index.php文件所在的位置)。
你的.htaccess应该包含:
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
另外在你的config.php中设置$ config [' index_page']为空:
$config['index_page'] = '';
查看文档:{{3}}
答案 3 :(得分:0)
试试这个:
RewriteEngine On
RewriteBase /projects/hc/homecare/trunk/homecare
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /projects/hc/homecare/trunk/homecare/index.php?/$1 [L]