I have problem with rewrite in CodeIgniter. I'm starting to study CI but the url is bothering me.
http: //localhost/projetoci/index.php/restrict
I already enabled rewrite mode in apache.
LoadModule rewrite_module modules / mod_rewrite.so
I created the .htaccess file
RewriteEngine on
RewriteCond $ 1! ^ (Index \ .php | resources | robots \ .txt)
RewriteCond% {REQUEST_FILENAME}! -F
RewriteCond% {REQUEST_FILENAME}! -D
RewriteRule ^ (. *) $ Index.php / $ 1 [L, QSA]
but none of this makes removing index.php from url. I've looked at other topics and couldn't solve it.
In application/config
folder, find and replace the below code in config.php file.
$config['index_page'] = "";
Now set .htaccess file as below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /projetoci/
#This bit rewrites your host name to include www
#RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /projetoci/index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /projetoci/index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /projetoci/index.php?/$1 [L]
</IfModule>
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.