remove index.php with alternative routing in codeigniter -
i'm working on project in codeigniter doesn't use standard routing.php file. calls functions this: test.vi/index.php/controller/function.
my goal remove index.php url htaccess rewrite:
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule .* index.php/$0 [pt,l]
and config.php change:
$config['index_page'] = '';
my question need route controllers/functions in route.php or can done without using route.php file?
first make sure enabled mod_rewrite in httpd.conf:
to add/make sure exsits line
loadmodule rewrite_module modules/mod_rewrite.so
then create .htaccess in codeigniter root folder (next index.php file) not application folder.
.htaccess
directoryindex index.php rewriteengine on rewritecond $1 !^(index\.php|img|css|js|robots\.txt|favicon\.ico) rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ ./index.php/$1 [l,qsa]
codeigniter take care of routings you; for
controlers/welcome.php method=hello
u can access
http://localhost/welcome/hello
its not laravel need add route; codeigniter automatically fitch controller you. unless have stored in different location or inside subfolder dont need touch route.php except setting default route.
Comments
Post a Comment