codeigniter コントローラ クラス関数を呼び出したい このように。しかし、これは機能していません。URLからindex.phpを削除したい

index.php を使用すると、これはうまく機能します URL から index.php を削除するにはどうすればよいですか?

私が変更され
$config['index_page'] = 'index.php';
に
$config['index_page'] = '';
しかし、それはうまくいきません
codeigniter コントローラ クラス関数を呼び出したい このように。しかし、これは機能していません。URLからindex.phpを削除したい

index.php を使用すると、これはうまく機能します URL から index.php を削除するにはどうすればよいですか?

私が変更され
$config['index_page'] = 'index.php';
に
$config['index_page'] = '';
しかし、それはうまくいきません
URL から index.php を削除するには、2 つの作業を行う必要があります。
最初のジョブ -
設定ファイルを変更しました
$config['index_page'] = 'index.php';
に
$config['index_page'] = '';
(すでに行っていること)
セカンドジョブ -
ルート ディレクトリに .htaccess ファイルを追加し、php mod_rewrite が有効になっていることを確認する必要があります。
詳細については、RewriteRuleのドキュメントを参照してください。
RewriteEngine on
RewriteRule ^([a-z0-9_-]+)\.html$ index.php/page/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|asset|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
これを試してみてください。それがうまくいくことを願って、何が起こっているのか教えてください。
次の内容でルート ディレクトリに .htaccess ファイルを作成します。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
.htaccess を使用した例の優れたリストは、http: //www.askapache.com/htaccess/modrewrite-tips-tricks.html にあります。
xampp を使用している場合は、以下の場所に htaccess ファイルを作成します。
" htdocs/codeigniter/.htaccess "
次に、htaccessコンテンツを配置します
への変更$config['index_page']は適切でしたが、あと 1 つ行う必要があります。
URLバーに必要なく、ファイル.htaccessへのすべての呼び出しをリダイレクトするcodeigniterルートディレクトリ内のファイルを使用する必要がありますindex.phpindex.php
私のファイルは次のようになります。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
### Canonicalize codeigniter URLs
# If your default controller is something other than
# "welcome" you should probably change this
RewriteRule ^(welcome(/index)?|index(\.php)?)/?$ / [L,R=301]
RewriteRule ^(.*)/index/?$ $1 [L,R=301]
# Removes trailing slashes (prevents SEO duplicate content issues)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)/$ $1 [L,R=301]
# Enforce www
# If you have subdomains, you can add them to
# the list using the "|" (OR) regex operator
RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
RewriteRule ^(.*)$ http://www.YOURSITE.COM/$1 [L,R=301]
# Enforce NO www
#RewriteCond %{HTTP_HOST} ^www [NC]
#RewriteRule ^(.*)$ http://YOURSITE.COM/$1 [L,R=301]
###
# 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]
# 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>
# Without mod_rewrite, route 404's to the front controller
ErrorDocument 404 /index.php
</IfModule>
このファイルは、すべての非 www 呼び出し ( のよう YOURSITE.comに) もリダイレクトしwww.YOURSITE.comます。別の方法で行うこともできます。その場合は、その部分を ( で#) コメントし、その下の部分を非推奨にする必要があります。
また、URL が改善されます (正規化された URL)。次の URL を参照してください。
/category
/category/index
/category/index/
これは、同じコントローラー内の同じ機能の 3 つの URL です。上記の.htaccess場合、URLは次のようになります
/category
注意すべきもう 1 つの重要な点:index任意の種類のパラメーターを受け取るメソッドを持つコントローラーの場合、これらの URL は引き続き次のように機能します。
/welcome/index/123
/category/index/123