CodeIgniter Forums
Best way of handling controller URL and segements - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Best way of handling controller URL and segements (/showthread.php?tid=68124)



Best way of handling controller URL and segements - CINewb - 05-29-2017

In my controller I find myself doing this a lot (where "configuration" is a sub-directory and "website" is the controller):


Code:
redirect('/configuration/website' );


and

Code:
$this->load->view('configuration/website/edit', $data );

Then in my view I have things like:


Code:
<a href="configuration/website/add" class="form-button">Add New Site</a>


and


Code:
<?php echo form_open( 'configuration/website/edit' ); ?>


The issue here is that if ever I change my controller name or its sub-directory, I'll have a lot of things to update in a few different files.

I've read up on the URL helper function current_url() and also $this->uri->segment(1), but I wondered if there is a "proper" way of dealing with this?

Thanks,


RE: Best way of handling controller URL and segements - InsiteFX - 05-29-2017

Read the CodeIgniter Users Guide on URI Routing


RE: Best way of handling controller URL and segements - kentran - 12-21-2017

(06-07-2017, 01:03 PM)bryandaniel1 Wrote:
(05-29-2017, 03:45 AM)InsiteFX Wrote: Read the CodeIgniter Users Guide on URI Routing

Thank you, i did it

Hello, did you succeed? Can you help me?