如何使用codeigniter隐藏浏览器URL

时间:2014-04-04 06:34:14

标签: php codeigniter

问题:

如何使用codeigniter隐藏浏览器URL?

我当前的网址:

http://localhost/civicsoft_local/index.php/civic_soft_control/login?state=0

预期网址

http://localhost/civicsoft_local/

CodeIgniter .htaccess文件内容如下:

RewriteEngine on
RewriteCond $1 !^(ci_civic_soft\index\.php|images|robots\.txt)
RewriteRule ^(.*)$ ci_civic_soft/index.php/$1 [L]

4 个答案:

答案 0 :(得分:0)

答案 1 :(得分:0)

  1. 在配置文件中编辑查询字符串。

     $config['enable_query_strings'] = FALSE;
    
  2. 在路线中更改您的默认网址

    $route['default_controller'] = "civic_soft_control/login/0";
    

答案 2 :(得分:0)

确保已安装并启用mod_rewrite并将其放入.htaccess文件中:

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

applicaiton/config/config.php文件中,请确保其中包含以下内容:

$config['uri_protocol'] = 'REQUEST_URI';

答案 3 :(得分:0)

确保您的.htaccess文件中包含以下内容。

RewriteEngine on
RewriteBase /

现在,在config.php文件中,您需要确保拥有以下内容

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

最后在您的路线文件中,您必须将缩短版本的网址映射到控制器/功能。

$route['default_controller'] = 'civic_soft_control/name_of_funtion';
相关问题