I'm using CodeIgniter v.3.0.4 and I'm unable to remove the 'index.php' from URL.
I've added the .htaccess file:
<ifmodule mod_rewrite.c=""> RewriteEngine On RewriteBase /project_01/ RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </ifmodule> <ifmodule !mod_rewrite.c=""> ErrorDocument 404 /index.php </ifmodule>
In application folder > config.php > I edited the value to:
$config['index_page'] = '';
And:
$config['uri_protocol']= 'REQUEST_URI';
And:
$config['base_url'] = 'http://localhost/Project_01/';
I checked that my Apache server conf file does not have the pound sign next to the line:
LoadModule rewrite_module modules/mod_rewrite.so
What am I doing wrong? Or what am I not doing?
It worked fine in prior versions of CI, what changed?
Because your rule is sending the request to the query string, you need to use QUERY_STRING
for the uri_protocol
, and not REQUEST_URI
.
As an alternative, and if you would like to keep REQUEST URI
, you can change the rule to either one of the following:
RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^ index.php [L]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.