News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso's Blog:
Protect files within public folders with mod_rewrite and PHP
November 29, 2010 @ 09:45:43

Gonzalo Ayuso has a new post that can help you protect certain files inside of a public folder by combining mod_rewrite and PHP.

Here's the problem. We have a legacy application (or a WordPress blog for the example) and we want to protect the access to the application according to our corporate single sign on. We can create a plug-in in WordPress to ensure only our single sign-on's session cookie is activated.

In his example, he shows the handling of an uploaded file and a plugin that can be used to protect parts of the site based on session information. Unfortunately, by itself, this doesn't prevent the direct access of the file. His trick is to route all file access back through a central "media.php" script that fetches it from a file location (could even be outside the docroot). The routing to the PHP is handled via mod_rewrite and the code checks the permissions on the current user's session for access.

0 comments voice your opinion now!
modrewrite public folder tutorial protect file wordpress


blog comments powered by Disqus

Similar Posts

Abhinav Singh's Blog: Get real time system & server load notification on any IM using PHP and XMPP

DevShed: Accessing Attributes and Cloning Nodes with the DOM XML Extension in PHP 5

PHPMaster.com: Pagination with CodeIgniter

SitePoint PHP Blog: Nginx, PHP5.5 and Phalcon on OpenShift

DeveloperTutorials.com: How to Install PHP 5 on Linux


Community Events





Don't see your event here?
Let us know!


release language library artisanfiles tool community symfony composer interview podcast list conference opinion series introduction security laravel framework voicesoftheelephpant version

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework