1

この投稿を開く前に、私はこれを理解しようと 3 日間費やしましたが、まったく運がなかったので、助けてください. ありがとう~~~~

わかりました、これは私がこれまでに行ったことです:

  1. CI 2.1.3 の新しいコピーをインストールします。どのフォルダーの名前も変更しません。
  2. Google で見つけたすべての構造を使用して、CI ROOT ディレクトリに新しい .htaccess ファイルを作成します。
  3. config['index_page'] を空に変更します。config['index_page'] ='';
  4. config['uri_protocol'] = 'REQUEST_URI' または 'QUERY_STRING' を設定</li>
  5. 上記の変更を行うたびに、MAMP(PHP 5.4)を再起動しても
  6. 有効: LoadModule rewrite_module modules/mod_rewrite.so in httpd.conf
  7. https.conf に「Options Indexes FollowSymLinks MultiViews」を追加します (よくわからないことだけ)。
  8. (今何を試せばいいのかわからない V_V )

それから、私はこれを得ました:

はい動作: http://ci.dev/index.php/welcome/index

動作していません: http://ci.dev/welcome/index

ここに私が今持っているものの詳細があります:

.htaccess ファイル:

# I got 500 error if I uncommend this line: <IfModule mod_rewrite.c>
#http://ci.dev/index.php/welcome/index  this is works fine only if the above line commend out
RewriteEngine On
RewriteCond $1 !\.(gif|jpe?g|png)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/?$1 [L]
# I got 500 error if I uncommend this line: </IfModule> 

config.php

$config['index_page'] = '';
$config['uri_protocol'] = 'QUERY_STRING';
//$config['uri_protocol'] = 'REQUEST_URI'; 

ホストファイル

127.0.0.1 localhost
127.0.0.1 test.dev
127.0.0.1 ci.dev 

httpd.conf ファイル

#the following line also enabled
LoadModule rewrite_module modules/mod_rewrite.so  in httpd.conf

...

# The following code I placed at the bottom of https.conf file

NameVirtualHost *

<VirtualHost *>
 ServerName localhost
 DocumentRoot "/Applications/MAMP/htdocs"
</VirtualHost>

<VirtualHost *> 
 ServerName ci.dev
 DocumentRoot /Users/coda/Sites/ci
 <Directory /Users/coda/Sites/ci>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all
 </Directory>
</VirtualHost>

<VirtualHost *> 
 ServerName test.dev
 DocumentRoot /Users/coda/Sites/test
</VirtualHost> 

私を助けてください~~~~

ありがとう

================================================== ===============

ここで私を助けようとするすべての人に感謝します。ようやくうまくいきました。単純なことを見落とした後、どうにかして物事を複雑にしすぎたと思います。

CI2 の別のコピーをインストールし、.htaccess ファイルを次のように変更するだけです。

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

その後、すべてがうまくいきます〜!!!! –</p>

4

4 に答える 4

3

この .htaccess を試してください (これをプロジェクト ディレクトリのルート、つまり /chat に入れます):

# To remove index.php from URL

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

RewriteBaseサブディレクトリにプロジェクトがある場合は置き、それ以外の場合は削除します

于 2013-03-12T07:31:23.003 に答える
1

index.php ファイルと一緒に、.htaccess ファイルをアプリケーションのルート ディレクトリに配置します。(htaccess 拡張子が正しいかどうかを確認してください。Bz htaccess.txt は機能しませんでした。)

そして、次のルールを .htaccess ファイルに追加します。

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

次に、application/config/config.php ファイルで次の行を見つけます。

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

以下のように変数を空に設定します。

$config['index_page'] = '';

それだけです、それは私のために働きました。

さらにうまくいかない場合は、次の変数をこれらのパラメーター ('AUTO'、'PATH_INFO'、'QUERY_STRING'、'REQUEST_URI'、および 'ORIG_PATH_INFO') で 1 つずつ置き換えてみてください。

$config['uri_protocol'] = 'AUTO';
于 2013-03-12T06:36:47.083 に答える
1

ここに画像の説明を入力

ノート:

htdocsはルート フォルダーです。

ci_introは、コード イグナイターのフォルダーです。

同じケースがある場合、.htaccess は次のようになります。

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /ci_intro/

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php
</IfModule>

RewriteBase /ci_intro/で ci_info を codeigniter のフォルダーに変更することに注意してください。

于 2013-03-12T07:23:44.463 に答える