I've been working in Codeigniter for a few days now & everything is going very well, accept I cant for the life of me get rid of the index.php in the url (from localhost/index.php/controller to localhost/controller).
I'm using CIs default index.php.
rewrite is enabled in apache.
$config['index_page'] = "";
$config['uri_protocol'] = 'AUTO';
(Though I've tried the other four settings for URI)
.htaccess looks like this.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 /index.php
</IfModule>
I've tried the answers here and here
help would be wonderful
Thank you
PS I'm working in a sub-domain if that matters.
Put the following rules to .htaccess file,
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
If the above lines don't work then you need to open your CI config file application/config/config.php
In that find the following line
$config['index_page'] = 'index.php';
Change that to:
$config['index_page'] = '';
If that does not work either then try changing uri_protocol to auto in config:
$config['uri_protocol'] = 'AUTO';
In .htaccess this could be a problem
RewriteCond $1 !^(indew\\.php|resources|robots\\.txt)
and make sure that that the rewrite module is enabled How to enable mod_rewrite for Apache 2.2
Or for the RewriteRule line, try changing it to this
RewriteRule ^(.*)$ /index.php/$1 [L]
(the /
before the index.php)
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.