This is my .htaccess file:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
And my routes.php file:
$route['default_controller'] = 'pages/view';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['(:any)'] = 'pages/view/$1';
Don’t they basically do the same thing? Which is correct to use?
*Edit: My question is not specific for this example. It is more like, which is good for what? It seems like they both to the same thing? Or am I wrong? *
The .htaccess file removes the index.php from the URL, whereas the routes.php file controls where the URI segments are pointing to in terms of controllers, actions, and parameters
in other words,
.htaccess is a directive to the apache server to remove index.php from the requested URL, and routes.php just directs your actual php scripts