2015-10-06 117 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 –