1

私は最初の個人的な 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 /madrigal/

            # 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|favicon\.ico|public|assets|css|js|images)

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

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

config.php ファイルを $config['index_page'] = ''; に設定しました。および $config['uri_protocol'] = 'REQUEST_URI'; しかし、コントローラー /admin/ に移動すると、URL の末尾に「/index」と入力しない限り、インデックスは実行されません。私のhtaccessファイルはそれを許可していませんか?

助けてくれてありがとう

4

2 に答える 2

1

以下のリンクで確認できます...

http://ellislab.com/codeigniter/user-guide/general/urls.html

また、

CodeIgniter URL から index.php を削除できません

于 2013-11-05T07:02:09.977 に答える
0

この index.php は、.htaccess ファイルといくつかの簡単なルールを使用して簡単に削除できます。

RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|img|js)
RewriteRule ^(.*)$ /index.php/$1 [L]

上記の例では、index.php、images、および robots.txt に対するもの以外の HTTP リクエストは、index.php ファイルに対するリクエストとして扱われます。ここでドキュメントを読むことができます

$config['index_page']URI で index.php を削除するためではなく、呼び出すデフォルト ページの構成です。

于 2013-11-05T01:18:08.173 に答える