在 codeigniter 中仅从我的主页中删除“/home”的方法
way to remove "/home" just from my home page in codeigniter
我是 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]
在您的 .htaccess
文件中使用此规则:
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ [L,R=301]
对于您的情况,也许这可能是解决方案。试试这个方法:
RewriteEngine on
RewriteBase /
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)$ https://%1/ [R=301,L]
RewriteCond !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
php_value session.cookie_httponly 1
php_value session.cookie_secure 1
只需在您的 .htaccess 中写入:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
和
$route['default_controller'] = "home";
在你的 routes.php
并检查
$config['base_url']='http://exemple.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
然后 example.com 将显示示例。com/home 控制器但不会显示 '/home' uri 段。对我来说很好
我是 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]
在您的 .htaccess
文件中使用此规则:
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ [L,R=301]
对于您的情况,也许这可能是解决方案。试试这个方法:
RewriteEngine on
RewriteBase /
RewriteRule ^(home(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ [L,R=301]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)
RewriteRule ^(.*)$ https://%1/ [R=301,L]
RewriteCond !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
php_value session.cookie_httponly 1
php_value session.cookie_secure 1
只需在您的 .htaccess 中写入:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L,QSA]
和
$route['default_controller'] = "home";
在你的 routes.php
并检查
$config['base_url']='http://exemple.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
然后 example.com 将显示示例。com/home 控制器但不会显示 '/home' uri 段。对我来说很好