eisenseinstein eisenseinstein - 4 months ago 25
PHP Question

Mixing of static and dynamic pages in CodeIgniter

I'm trying to mix static and dynamic content in a CodeIgniter 3.1 tailored website. I'm using the tutorial example given for the static content:

$route['default_controller'] = 'pages/view';
$route['(:any)'] = 'pages/view/$1';


I'm afraid this would be quite messy for the purpose, since (:any) is too generic and I don't want to use something like
"/static/(:any)"
route.

Any suggestions on how to achieve a solution that let me have a static and controller named friendly URL?

Every idea is welcome and very much appreciated.




As my question seems to be difficult to understand, I'll try to ask it once again:

Is there a way to combine static content with the above code (from codeigniter tutorial) and the usual approach
http://example.com/controller/index_named_method
dynamic content handling?

Can you give an example?

Should I change
$route['(:any)']
for every static webpage's name i.e.:
$route['(home|contact|links)']
?

Thanks in advance

Answer

Consider this:

$route['(:any)'] = 'pages/view/$1';

In function get the name / Parameter by uri segment. Have a DB with - SEO URL and your controller/function - and Redirect to it.

Its an example. Try it with your app...!

Happy Coding!