私は CodeIgniter の初心者で、最初のプロジェクトを仕上げています。ただし、ホスティング サイトに配置する前に、CodeIgniter が構成フォルダーで提供する routes.php ファイルを使用して URL をクリーンアップしたいと考えています。
私のサイトは、次の URL を使用して読み込まれます。
http://fakehost:8888/TheWorksPlumbing/index.php/theWorksPlumbingController/index/home
http://fakehost:8888/TheWorksPlumbing/index.php/theWorksPlumbingController/index/about
http://fakehost:8888/TheWorksPlumbing/index.php/theWorksPlumbingController/index/services
また、次のデフォルトのコントローラー URL を使用してホームページをロードします。http://fakehost:8888/TheWorksPlumbing/
ただし、サイトの各ページに URL を設定したいのですが、うまくいきません。たとえば、次のようにします。
http://fakehost:8888/TheWorksPlumbing/home
http://fakehost:8888/TheWorksPlumbing/about
http://fakehost:8888/TheWorksPlumbing/services
theWorksPlumbingController コントローラ ファイルのコードは次のとおりです。
class TheWorksPlumbingController extends CI_Controller {
public function index($page = 'home'){
if ( !file_exists('application/views/'.$page.'.php') ) {
show_404();
}
$this->load->view('templates/header');
$this->load->view($page);
$this->load->view('templates/footer');
}
}
これは、動作していない routes.php ファイルのコードです。
$route['default_controller'] = "theWorksPlumbingController";
$route['404_override'] = '';
$route['(:any)'] = "index.php/theWorksPlumbingController/index";
サイトが /home または /about または /services のみをロードするようにするには、何を追加または変更する必要がありますか?