I have been combing the documentation and I keep coming up with close to nothing. What I want to do is as follows: 1. I have an app(codeigniter app) all I want to do is protect the dynamic view of a project. The dynamic url is /projects/show/(var) CI is a MVC controller so /projects/show/id are all dynamic and ran through a htaccess file which filters everything through index.php I do not want to use my own members login/db/etc aMembers is fine. How do I restrict access to that specific call? Thanks.
If everything is handled through index.php you can protect that file using php_include. Can you show .htaccess file with rewrite rules that handle redirects?
Yeah the problem is that index.php is not the point I want to secure, index.php fires up the front controller pattern. routes the incoming request through it, finds the proper controller and method and fires off that method which takes the last part of the request sends the query to the db and populates a view with the info. So mydomain.com/projects/show/1/a-fancy-project triggers Projects_Controller::show( array('1', 'a-fancy-project' ); which contains calls to the db and a view which is "views/projects/show.php" as where mydomain.com/projects triggers Projects_Controller::index() same as above but different calls to the db and a view of "views/projects/index.php" all routed through the framework. What I want to do is protect a single view from within the framework, I've tried adding in the php include in the view (show.php) that I want to protect. And it does not work. it does not like the dynamic url. Here is my .htaccess # Turn on URL rewriting RewriteEngine On # Installation directory RewriteBase / # Protect application and system files from being viewed RewriteRule ^(application|modules|system) - [F,L] # Allow any files or directories that exist to be displayed directly RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d # Rewrite all other URLs to index.php/URL RewriteRule .* index.php/$0 [PT,L]
So, my suggestion will work still. In index.php you can access $_SERVER['PATH_INFO'] in your example it will be: /show/1/a-fancy-project So then just do something like this in index.php: if($_SERVER['PATH_INFO'] == '/show/1/a-fancy-project'){ //protection code here. } Of course this is just an example, the better way is to split PATH_INFO into an array and test each array element. Or use preg_match.