2016-07-20 10 views
2

私はCodeIgniter 3でプロジェクトをやっています。私はindex.phpをURLから削除する必要があります。そのためには、CodeIgniter 3のファイル.htaccessと、このファイルをどこに置くのかを教えてください。CodeIgniter 3のURLからindex.phpを削除します。

これは私のBASEURLあなたconfig.phpメイク次の変更で

http://cableandmedia.com/demo/ 
+2

可能性のある複製http://stackoverflow.com/questions/1445385/how-to-remove-index-php-in-codeigniters-path、あなたは質問する前にそれを検索する必要があります –

+0

これは重複する質問だけでなくCodeIgniterのドキュメント(http://www.codeigniter.com/user_guide/general/urls.html#removing-the-index-php-file)で[その答えははっきりと綴られています]見てください。 – Sparky

答えて

5

メインプロジェクトディレクトリに.htaccessファイルを追加するには、以下のコード

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

および設定ファイル内であなたのhtaccessファイルを更新し、でベースURLを変更してくださいコード: -

$root = "http://".$_SERVER['HTTP_HOST']; 
$root .= str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']); 
$config['base_url'] = $root; 
+0

私はアプリケーションフォルダ内か、アプリケーションフォルダ内にファイルを置くべきですか? –

+0

アプリケーションファイルと一緒にファイルを置きます。 –

+0

"入力ファイルが指定されていません。 –

2
place your htacces file in the root directory and use this following code 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 
+0

ありがとうございます、それは私の仕事です。 –

1

です。

$config['index_page'] = ''; 

そして、次の内容

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

<Files "index.php"> 
AcceptPathInfo On 
</Files> 
0

ファイル:config.phpの

$config['index_page'] = ''; 

ファイル:.htaccessの

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

RewriteEngineでは、サーバーに入って来るとregular-に基づいてURLリクエストを書き換えることができます式パーサー。

0

まあ、私が何をしたか。ここ

は、

私は/この

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

や "アプリ/設定/ config.phpを"

$config['base_url'] = ''; 
$config['uri_protocol'] = 'AUTO'; 
に ".htaccessファイル" を作成、編集しました

と "app/libraries/Template.php"

define("PATH", base_url()."index.php/"); 
define("BASE", base_url()); 

乾杯!

関連する問題