How do I remove the \"index.php\"
sticking out in every path in codeigniter somewhere in the center?
I want clean non index.php-fied URLs
?
I had some big issues with removing the index.php. As a general rule the .htaccess below has been tested on several servers and generally works:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
<Files "index.php">
AcceptPathInfo On
</Files>
If you don't have any luck with that then the next step is to adjust your config file. Try some of the other URI protocols e.g.
| 'AUTO' Default - auto detects
| 'PATH_INFO' Uses the PATH_INFO
| 'QUERY_STRING' Uses the QUERY_STRING
| 'REQUEST_URI' Uses the REQUEST_URI
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
$config['uri_protocol'] = 'ORIG_PATH_INFO';
If your still not having any luck try changing the rewrite rule to include your subfolder. This is often a problem if your using a temporary URL on a dev server etc:
RewriteRule ^(.*)$ /subofolder1/subfolder2/index.php/$1 [L]
Just play around with these options, one should work. Also, make sure your index file is set to:
$config['index_page'] = '';
Good luck!
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
This must definitely work.. have a try
Ensure you have enabled mod_rewrite
(I hadn't).
To enable:
sudo a2enmod rewrite
Also, replace AllowOverride None
by AllowOverride All
sudo gedit /etc/apache2/sites-available/default
Finaly...
sudo /etc/init.d/apache2 restart
My .htaccess is
RewriteEngine on
RewriteCond $1 !^(index\.php|[assets/css/js/img]|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
If you are on linux and using apache2 server then we may need to override apache2.conf file also beside changes on .htaccess file. Find apache2 configuration file on /etc/apache2/apache2.conf .
Search Directory /var/www/ Change AllowOverride None -> AllowOverride All
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory
Use mod_rewrite
as instructed in this tutorial from the CI wiki.
Just thought i might add
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
would be the .htaccess and be sure to edit your application/config.php variable in the following manner:
replace
$config['uri_protocol'] = “AUTO”
with
$config['uri_protocol'] = “REQUEST_URI”