Reputation: 77
I try to remove the index page in Codeigniter
the first step I do this //old Code
$config['index_page'] = "index.php”
//New updated code(Only Need to remove index.php )
$config['index_page'] = ""
then for second step i do this creat file .htaccess in root of codigniter then put this code source
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
but it's the same problem and I can't refresh the web page
with index page the URL work: http://localhost:8089/codeigniter3/index.php/Hello/dispdata but without index page don't work http://localhost:8089/codeigniter3/Hello/dispdata
Hello is the controller, finally thank for help, :)
Upvotes: 4
Views: 324
Reputation: 1313
The problem is, you installed it in /codeigniter3/
This should fix it:
// remove index.php
$config['index_page'] = ""
// Allow installation in a subfolder of your webroot
$config['uri_protocol'] = "REQUEST_URI"
And keep your rewrite settings, they are ok.
Upvotes: 4
Reputation: 11
Create a new File In Main Folder Named as (.htaccess) and paste this code in .htaccess file.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /Enter your folder name/
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 ^(.*)$ /index.php?/$1 [L]
When your application folder isn't in the system folder This snippet prevents user access to the application folder
Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
Checks to
Rewrite Cond %{ENV:REDIRECT_STATUS} ^$
Rewrite Cond %{REQUEST_FILENAME} !-f
Rewrite Cond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
ErrorDocument 404 /index.php
Upvotes: 1
Reputation: 45829
RewriteRule ^(.*)$ index.php/$1 [L]
Since you are passing the correct URL-path as additional pathname information (path_info) in your .htaccess
directive then try explicitly setting this in the config:
$config['uri_protocol'] = 'path_info';
Unless this is set explicitly then it will try various methods, which may be failing since you have now removed index.php
from the URL.
Upvotes: 0
Reputation: 80
Can you try the below code in your .htaccess
file on root folder
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
Upvotes: 0
Reputation: 1675
Try this step:
$config['index_page'] = "index.php"
create .htaccess
in the project root folder like below code
RewriteEngine on
RewriteBase /codeigniter3/
RewriteCond $1 !^(index\.php|css|fonts|images|js)
RewriteRule ^(.*)$ index.php?/$1 [L]
Then try http://localhost:8089/codeigniter3/Hello/dispdata
I hope it will fix your problem!
Upvotes: 0
Reputation: 93
Codeigniter url routing should come to your rescue. Refer: https://codeigniter.com/user_guide/general/routing.html
Upvotes: 1
Reputation: 706
Please follow the below process:
.htaccess
file in the project root folderCheck whether mod_rewrite is enable on server?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]`
This will resolve your issue. Let me know if you are still facing issue.
Upvotes: 0
Reputation:
try this
RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
QSA
means that if there's a query string passed with the original URL, it will be appended to the rewrite
And then do this
//remove index.php
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
Upvotes: 0