この質問は Server Fault に適していることは承知していますが、残念ながら、質の低い質問のために禁止されました (私が行った 2 ~ 3 の質問に反対票が投じられました)。
CodeIgniter ルーティングに関連する 2 つの問題があります。
index.php
最初の問題は、URLを取り除くことができないように見えることです。削除方法の指示に従いました。WAMP サーバーのルートにある .htaccess ファイル (以下を参照) に次の mod 書き換えコードがあります (CI は独自のフォルダーではなくルートにあります)。httpd.conf
fileのこの行のコメントを外しましたLoadModule rewrite_module modules/mod_rewrite.so
。から削除index.php
しまし$config['index_page'] = "index.php";
た。そして、すべての WAMP サービスを再起動しました。
私の2番目の問題は、と呼ばれるコントローラーとsearch
と呼ばれるメソッドがあることindex
です。http://localhost/index.php/search/index
結果の URL を からに変更したいと思いますhttp://localhost/search/whatever_im_searching_for
。routes.php ファイルで次のカスタム ルートを試しましたが、うまくいきませんでした。$route['search/(.*)'] = "search/$1";
RewriteEngine On
# Put your installation directory here:
# If your URL is www.example.com/, use /
# If your URL is www.example.com/site_folder/, use /site_folder/
RewriteBase /
# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
.htaccess
CI のカスタム ルーティングの使用方法に関するコードを理解するのに苦労しています。どんな援助でも大歓迎です。前もって感謝します。
編集1