can PHP actually control the reading of a folder?
The Web server, operating system has Windows Server 2003 and CentOS Linux 5.2 two kinds. Inside there is a folder pay, which has a large pile of pure static. htm files. For example:
Http://www.example.com/pay/abc.htm
Http://www.example.com/pay/efg.htm
Http://www.example.com/pay/hij.htm
Http://www.example.com/pay/klm.htm
Only premium paid users can open and read these pages. When other users try to open, they will automatically jump to the Login.htm Web page and ask the user to log in.
Can PHP actually implement this seemingly simple function? I've wanted to use PHP and cookies or sessions before, but they're static. htm files that PHP can't control directly.
Do you want to convert all the files into PHP files and then insert the code in each PHP file to determine if the browser has a cookie:
PHP Code
if (!isset ($_cookie[' check ')) {header (' Location:login.htm ');}? >
But this is too much work, and the Pay folder contains thousands of pure static. htm files.
is there a better way?
------Solution--------------------
Estimate pseudo-static, or dynamic page, if the dynamic is good, including a public page validation
If it's static, you can make it into a template page. There are a variety of ways to load a static page
URLs do not think about what to write, folder that is to set permissions
------Solution--------------------
Do you send the URL directly to the client? This idea is wrong.
Regardless of the type, files that need to be protected cannot send the original URL to the client, which is the basic principle
Use fopen to read the echo display again