我想从我的url中删除"index.php“
http://localhost/simpleblog/index.php/blogger/NewBlogs
我需要它作为
http://localhost/simpleblog/blogger/NewBlogs
这里显示了我的控制器代码
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');
}
}
默认控制器
public function index()
{
$this->load->helper('url');
$this->layout="Yes"; //<-- add this*/
/* $this->load->view('welcome_message');*/
$this->load->view('Pages/MainPage');
}
如何删除index.php?
发布于 2013-09-25 01:24:29
正在删除index.php文件
默认情况下,index.php
文件将包含在URL中:
example.com/index.php/news/article/my_article
您可以通过使用带有一些简单规则的.htaccess
文件轻松地删除此文件。
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
发布于 2015-08-17 01:03:55
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
发布于 2018-06-09 00:58:05
您应该在.htaccess文件中输入此代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
并在config.php文件中替换此代码
$config['index_page'] = 'index.php';
To
$config['index_page'] = '';
https://stackoverflow.com/questions/18987639
复制相似问题