删除" / home"的方法就在我在codeigniter

时间:2016-03-15 00:16:53

标签: codeigniter codeigniter-3

我是Codeigniter的新手。 我希望我的主页设置为" example.com"而是作为" example.com/home"目前。

我的routes.php是这样的:

$route['default_controller'] = "home";

一切正常,只需要知道是否有办法删除" /home"就在我的主页上。其他地方都很好。

的.htaccess

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

2 个答案:

答案 0 :(得分:1)

.htaccess文件中使用此规则:

RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

在你的情况下,也许这可能是解决方案。试试这个:

RewriteEngine on
RewriteBase /

RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]

RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

php_value session.cookie_httponly 1
php_value session.cookie_secure 1

答案 1 :(得分:0)

只需写下你的.htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

$route['default_controller'] = "home";
你的routes.php中的

并检查

$config['base_url']='http://exemple.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

然后example.com将显示example.com/home控制器,但不会显示' / home' uri段。它适用于我

相关问题