2017-01-02 14 views
1

私はCodeIgniterの3CodeIgniterの3ルーティングエラー

にエラーをルーティング取得していますが見つかりませんでした 要求されたURL /index.phpは、このサーバー上に見つかりませんでした。 Apache/2.4.7(Ubuntu)サーバ

私は何をしましたか? 私の.htaccessは

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

はまた

AllowOverride ALLを設定する私のコントローラtest.phpを

class Test extends CI_Controller { 
    public function index(){ 
     print_r('test'); 
     die(); 
    } 
} 

マイルート:$route['test/(:any)'] = 'test/$1';

とURLでこのページにアクセスしてみてください:

http://localhost/codeigniter/test/index.php 
http://localhost/codeigniter/test/ 

答えて

0

あなたはだけのタイプのコントローラにアクセスしている場合は、この.htaccess

RewriteEngine on 

RewriteCond $1 !^(index\.php|assets|image|resources|robots\.txt) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 

を試してみて、(プロジェクトフォルダ名としてcodeigniterを仮定)

http://localhost/codeigniter/test/ 

何ですかこの理由は$route['test/(:any)'] = 'test/$1';

これは、引数が渡されることを指名します。それは数字または文字にすることができます。例http://localhost/codeigniter/test/aaaまたはhttp://localhost/codeigniter/test/25


Look at this

+0

お手伝いします:) –

0

あなたの問題は、あなたが(2)、URIが(2)コントローラのメソッドのために意図されたURIを渡すことで、あなたはあなたが指定する必要があり、このルートcodeigniter/test/1を使用しようとすると、あなたの方法はまずそうそれはこのように行く$route['test/(any)'] = 'test/index/$i'; btw codeigniterあなたのuri(0)と考えています。

関連する問題