2015-10-06 119 views
2

我想,当我输入localhost /项目名称/ index.html的它会重定向到通过URL重定向的.htaccess不会在Php笨工作

http://localhost/service/welcome/index 

为此,我写在.htaccess但不起作用

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

Redirect /index.html http://localhost/service/welcome/index 

我该怎么做?

回答

2

在codeigniter中有没有文件在URL中调用。所有Codeigniter所做的是使用MVC结构来渲染视图。

以及如果您访问根文件夹(index.html或index.php)上的任何内容,它将重定向到应用程序文件夹。然后默认控制器是触发。

CZ根有文件调用index.php,那里你可以看到

$application_folder = 'application'; 
$system_path = 'system'; 

而且你可以看看这个

  1. 路线 - config/routes.php
  2. 控制器 - controller/
  3. 模型 - model/
  4. view - view/

我们使用.htaccess删除URL中的index.php

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 

,如果你想添加URL的.html.php年底

config/config.php

/* 

    |-------------------------------------------------------------------------- 

    | URL suffix 

    |-------------------------------------------------------------------------- 

    | 

    | This option allows you to add a suffix to all URLs generated by CodeIgniter. 

    | For more information please see the user guide: 

    | 

    | http://codeigniter.com/user_guide/general/urls.html 

*/ 
$config['url_suffix'] = ''; 
+0

湖中有没有重定向选项? –

+0

那我该如何重定向或触发呢? –

+0

什么重定向?我们使用.htaccess删除index.php中的URL –