Tuesday, March 15, 2022

[FIXED] Remove index.php from URL in CI?

Issue

I removed index.php from the URL in CodeIgniter. I have already changed the .htaccess file data. But I want to know that is there any other way to remove the index.php from the URL or through any other .htaccess data. Means this is only a way or not.

In .htaccess file I wrote this :

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Solution

Try this :

Make sure you have enabled rewrite_module on your Apache modules

.htaccess

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|indexcp\.php?|resources|robots\.txt)
RewriteRule ^([A-Za-z0-9_/.-]+)$ index.php?/welcome/$1

Open config.php :-

$config['index_page'] = '';

$config['base_url'] = 'http://www.example.com/';  //your site name

$config['uri_protocol']= 'REQUEST_URI';


Answered By - Rakesh Shetty

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.