![]() |
URI - Routing - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: URI - Routing (/showthread.php?tid=68144) |
URI - Routing - consigliere - 06-01-2017 Hi, for example let's say we have a static page: site.com/contact and our Controller should look like: PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); in order to do that we will put in our config/routes.php PHP Code: $route['contact-us'] = 'contact/index'; But the problem here is that a user can access the contact page from 2 url-s: site.com/contact and site.com/contact-us But, we want access to contact form from only one from this url: site.com/contact-us Can we set up somewhere that only routes specified in config/routes.php are 'valid' and if user access a contact form via site.com/contact to see 404 page? At them moment I am doing things like this in controller: PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Thanks RE: URI - Routing - Krycek - 06-01-2017 Why not removing the index() PHP Code: $route['contact-us'] = 'contact/show_ContactUs'; And your controller PHP Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |