Setting up routing in CodeIgniter

Good day to all… I have a question, how to implement the following:
there is a link like[news-id]and you need to change it so that the link works at[news-id]Displaying via[news-id]is already done. Thank you.

Answer 1, authority 100%

Try adding the following to your routes.php file:

$route['(:num)']  = 'news?id=$1';

meaning $1is [news-id]

Where is the link to


Replace with


If this doesn’t work, maybe the .htaccess file at the root of the site should contain these lines?

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|img|styles|demo|files|js|recommend|products|partner)
RewriteRule ^(.*)$ /index.php?/$1 [L]