CodeIgniter Forums
how to replace codeigniter urls with htaccess or route - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: how to replace codeigniter urls with htaccess or route (/thread-60283.html)



how to replace codeigniter urls with htaccess or route - El Forum - 02-22-2014

[eluser]Ahmed Iqbal[/eluser]
Hello, i want to replace codeigniter urls with my own urls, i think .htaccess will help me to get desire urls or route with some regex, please check our ci urls, and suggest htaccess code... in single quotations, we are passing values, in codeigniter urls, 'page' & 'category' represent controller.

For Pages:

codeigniter URL:
Code:
http://domain.com/page/'category-name'/'page-title'/

I want:
Code:
http://domain.com/category-name/page-title.html
For Category:

Codeigniter URL:
Code:
http://domain.com/category/'category-name'/

I want:
Code:
http://domain.com/category-name/

AND

Codeigniter URL:
Code:
http://domain.com/category/'category-name'/'index'/

I want:
Code:
http://domain.com/category-name/index.html


Currently, we are using route something like that:

Code:
$route['default_controller'] = 'home';

$route['category/(:any)/lists/(:any)'] = 'category/lists/$1';

$route['category/(:any)'] = 'category/index/$1';

$route['page/(:any)/(:any)'] = 'page/index/$1';