0

Windows7オペレーティングシステムにApache2.2、Php 5.4.5、Mysql5.5.27をインストールしました。私のローカルホストの場所はG:/local_serverです。CodeIgniter_2.1.3をダウンロードし、local_serverに抽出して、CodeIgniterの名前を変更しました。CodeIgniterフォルダーに.htaccessファイルを作成し、次のコードを貼り付けます。

<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On

# If your website begins from a folder e.g localhost/my_project then 
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase / CodeIgniter/

# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|assets|forums)

# No rewriting
RewriteRule ^(.*)$ - [PT,L]

# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>

次に、application / config/config.phpから次の行を変更しました

$config['index_page'] = 'index.php';  to $config['index_page'] = '';

$config['uri_protocol'] = 'AUTO'; to $config['uri_protocol'] = 'REQUEST_URI';

次の行でApachehttpd.confから#も削除しました。

LoadModule rewrite_module modules/mod_rewrite.so

しかし、それでも、CodeIgniterからindex.phpファイルを非表示にすることはできません。:(

感謝します。:)

4

1 に答える 1

8

これが私の良い'ol信頼できるCodeigniter.htaccessファイルです:

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

次に、ベースを必要なものに書き直し、アクセスする必要のあるディレクトリを追加します(テンプレートとプラグインがあります)。これで準備完了です。

もちろん、Apacheでmod_rewriteが有効になっていることも確認してください。有効になっていないと、どこにもアクセスできません。

于 2013-03-12T21:54:34.473 に答える