dropping the function from the uri - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: dropping the function from the uri (/showthread.php?tid=14774) |
dropping the function from the uri - El Forum - 01-14-2009 [eluser]juddmuir[/eluser] I'm building an app that includes a classifieds board, and I'm trying out codeignitor for the first time, though by no means a php newbie! I have three questions, relating to structuring a CI site directory: 1. If I want the URI like this: example.com/classifieds/category/123_posting_title, how do I drop the implicit function "display" from the URL? I.e. the class is "classifieds", and the function parameters are "category" and "posting_title" - but I don't want the function "display" in the URL. (Yes, I have an SEO background too...) 2. The site also has non-CI code on URLs like example.com/forum - how do I prevent CI from latching on to those URLs? Or should I say, what's the best practice for codeignitor and non-CI code to live in the same site directory? 3. Where does css and javascript go in the folder structure? I'd prefer to have it outside the system directory, so that non-CI code and CI code can both share the same css files, is that good CI practice? Thanks in advance for any replies! dropping the function from the uri - El Forum - 01-14-2009 [eluser]Colin Williams[/eluser] 1. Use a _remap() method in your classifieds controller. _remap() will be called regardless of the second URI parameter. You can then server up the appropriate method with whatever arguments you need. Read the Controllers section of the user guide for more details. 2. CI does not "latch" onto any URL by default. By default, it is just an index.php file that only executes when it's requested. You have probably employed mod_rewrite rules in order to get the index.php file to be requested regardless of the URI. So, you need to modify your mod_rewrite rules so this doesn't happen for the /forum URI. 3. You can put these assets anywhere you want. But remember, just as in no. 2, you need to make sure you aren't telling apache to rewrite requests for these assets to the index.php file. dropping the function from the uri - El Forum - 01-14-2009 [eluser]Creative Stasis[/eluser] judd, For one and two it sounds like you'll want to look into URI Routing. [ http://ellislab.com/codeigniter/user-guide/general/routing.html ]. I think your solution will be in there. For #3, I think it's going to be a subjective answer. I personally put it on the root (httpdocs, public_html... ). I'm the same way, I don't like to mix my css/javascript/images with CI code. dropping the function from the uri - El Forum - 01-14-2009 [eluser]Colin Williams[/eluser] _remap() is better for trickier URI schemes than setting up tricky routing rules. And #2 isn't about how CI routes a request, it's about how Apache routes the request. dropping the function from the uri - El Forum - 01-14-2009 [eluser]Creative Stasis[/eluser] Never have looked into _remap(). Will be really useful in the future. dropping the function from the uri - El Forum - 01-14-2009 [eluser]juddmuir[/eluser] Thanks for the replies, I'll get cracking on these tomorrow! dropping the function from the uri - El Forum - 01-14-2009 [eluser]Colin Williams[/eluser] I think I end up using _remap() in every controller I write. The flexibility it affords is extremely useful. |