I have a routing issue in CodeIgniter, i have searched and tried other links on stackoverflow including Removing index.php in CodeIgniter just works for the default controller URL but my problem did'nt solved. When i run from this url http://localhost/MyProject/ it successfully gives output the view page of test.php page, but the problem is suppose there is test2 view and controller also, so i can't load it directly by this url http://localhost/MyProject/test2 , but i can load it through http://localhost/MyProject/index.php/test2. I want that i can run my code without index.php in between url i.e. by http://localhost/MyProject/test2.
View
test.php
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<title>Welcome Test </title>
</head>
<body>
<div>
<span>Test 1</span>
</div>
</body>
</html>
Controller
test.php
<?php
class test extends CI_Controller{
function __construct(){
parent::__construct();
}
public function index(){
$this->load->view('test');
}
}
?>
routes.php
$route['default_controller'] = "test";
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
#rename "MyProject/" with your application directory
#For example you rename the entire CodeIgniter application as "mysite"
#then, the "RewriteBase /" will be like this "RewriteBase /mysite"
#same as at line number 10, "RewriteRule ^(.*)$ /MyProject//index.php #/$1 [L]" will be like this "RewriteRule ^(.*)$ /mysite/index.php/$1 [L]"
RewriteBase /MyProject/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /MyProject/index.php/$1 [L]
</IfModule>