Reputation: 199
I want remove "index.php" from my url
http://localhost/simpleblog/index.php/blogger/NewBlogs
I need it as
http://localhost/simpleblog/blogger/NewBlogs
here shows my Controller Code
class Blogger extends CI_Controller {
public function NewBlogs()
{
$this->load->helper('url');
$this->layout="Yes"; //<-- add this*/
/* $this->load->view('welcome_message');*/
$this->load->view('Pages/SecondPage');
}
}
Default Controller
public function index()
{
$this->load->helper('url');
$this->layout="Yes"; //<-- add this*/
/* $this->load->view('welcome_message');*/
$this->load->view('Pages/MainPage');
}
How to remove index.php ?
Upvotes: 1
Views: 503
Reputation: 46
You should enter this code in your .htaccess file
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
And replace this code in config.php file
$config['index_page'] = 'index.php';
To
$config['index_page'] = '';
Upvotes: 0
Reputation: 361
Removing the index.php file
$config['index_page'] = 'index.php';
replace with
$config['index_page'] = '';
i.e /.htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
save your file with name .htaccess
Upvotes: 0
Reputation: 1
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
Upvotes: 0
Reputation: 3622
By default, the index.php
file will be included in your URLs:
example.com/index.php/news/article/my_article
You can easily remove this file by using a .htaccess
file with some simple rules.
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
See Documentation
Upvotes: 1