codeigniter:URLのindexを削除します.php


URLのindexを削除します.php
まず、自分のWebサーバがApacheであることを理解し、mod_をサポートします.rewriteは、rewriteに関連するパラメータを構成しています.rewrtieとはGoogleでいいです.次に、CIルートディレクトリ(index.phpと同級)の下で、次のように新しいプロファイルを作成します.htaccessは中にこう書いてあります.
RewriteEngine on  
RewriteCond $1 !^(index\.php|images|robots\.txt)  
RewriteRule ^(.*)$ /index.php/$1 [L]
 
indexを取り除くことができます.phpです.注意/index.php/$1は、あなたのディレクトリ(Webディレクトリ、例えばhttp://www.domain.com/index.php)の実際の状況は、例えばウェブサイトのルートディレクトリが/ci/indexである.phpは/ci/indexと書く.php/$1
RewriteCond $1 !^(index\.php|images|robots\.txt)
 
上記のコードは、これらのディレクトリがindexにrewriteされないように、いくつかのディレクトリまたはファイルを排除することを意味する.phpでは、画像、js、cssなどの外部リソースで一般的に使用されます.つまり非PHPコードは除外されます.(ここではimagesディレクトリとrobots.txtファイルを排除しました.もちろんindex.phpも排除すべきです)ああ、そうだconfigも修正します.phpこのファイルの次の内容は次のとおりです.
/*
|--------------------------------------------------------------------------
| Index File
|--------------------------------------------------------------------------
|
| Typically this will be your index.php file, unless you've renamed it to
| something else. If you are using mod_rewrite to remove the page set this
| variable so that it is blank.
|
*/
$config['index_page'] = "index.php";
 
その中の「index.php」を「」に変えればいいです.もう一つ:まずapacheのプロファイルhttpdを設定します.conf、デフォルトは/apache/conf/ディレクトリです.mod_を開くrewrite.soモジュールは、rewriteを行う必要があるディレクトリ属性をAllowOverride Allに設定します.次に、Codeigniterの
ダウンロード (3.43 KB)
2009-1-20 11:49
ダウンロード (6.23 KB)
2009-1-20 11:41
config.phpファイル.デフォルトは/system/application/configディレクトリです.$config['index_page']="index.php"の項目を$config['index_page']=""";最後に、書きます.htaccessファイル、CIディレクトリにファイルを置けばいいです.ここで私にあげます.htaccessファイルの内容は皆さんの参考にしてください.
<IfModule mod_rewrite.c>
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>

Options -Indexes
Options +FollowSymLinks

#        SSI  
Options +Includes

#  404,500    
ErrorDocument 404 /404.htm
ErrorDocument 500 /404.htm

#        
DirectoryIndex index.php
order deny,allow

RewriteEngine on

#     
RewriteBase /www/ci_170/

#       index.php   
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index.php|images|robots\.txt)

RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>
 
ダウンロード (2.36 KB)
2009-1-20 11:49
注意:ルートディレクトリが設定されていない場合は、ルールのindexが必要です.phpの前にディレクトリに最終効果図を追加します.