将主页网址重定向到主域

时间:2015-12-29 04:08:06

标签: php .htaccess

我想将家庭控制器重定向到我的域名,它应该看起来像这样

http://sample.com/home to http://sample.com

http://sample.com/home/index to http://sample.com

http://localhost:8888/sample/home to http://localhost:8888/sample/

http://localhost:8888/sample/home/index to http://localhost:8888/sample/

有可能吗?怎么做?

1 个答案:

答案 0 :(得分:1)

当您需要重定向到主页$config['base_url'] = 'http://sample.com/';

URL Helper

在您的配置base_url()上确保已设置

$config['index_page'] = '';

您可能需要删除index.php并在主目录中包含合适的htaccess文件。

Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

主目录的Htaccess示例

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

您的家庭控制器路由应在默认路由应用程序上设置 - > config - > routes.php

Codeigniter URI Routing User Guide Page

$autoload['helper'] = array('url');

然后自动加载网址助手

redirect('/');

如果您需要重定向到家庭控制器,请确保文件名为Home.php

并使用compile 'com.google.android.gms:play-services-location:7.5.0' compile 'com.google.android.gms:play-services-ads:+'

注意:Codeigniter 3区分大小写,确保首字母大写在文件名和类名上大写

相关问题