Can PHP control the reading of a folder? Example: Can http://www.example.com/pay/abc.htmhttp://www.e PHP control the reading of a folder?
There are two types of website servers in the operating system: Windows Server 2003 and CentOS Linux 5.2. there is a folder named pay, which contains a pile of pure. 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 advanced paying users can access and read these webpages. when other users attempt to open these webpages, they will automatically log on to the login.htm webpage, requiring users to log on.
Can PHP implement this seemingly simple function? I used to think about using PHP and cookies or sessions, but they are static. htm files and PHP cannot directly control them.
Is it necessary to convert all these files into PHP files, insert code into each php file, and determine whether the browser has a Cookie:
PHP code
if(!isset($_COOKIE['check'])){header('Location:login.htm');}?>
However, this process is too heavy, and there are thousands of pure. htm files in the folder.
Is there a better way?
------ Solution --------------------
It is estimated that the pseudo-static state is still a dynamic page. if it is dynamic, it is easy to do, including a public page for verification.
If it is static, you can make it a template page. There are many ways to load a static page,
You don't have to worry about writing a URL into a folder.
------ Solution --------------------
Do you directly send the url to the client? This idea was originally wrong.
No matter what type, the file to be protected cannot send the original url to the client. this is the basic principle.
Use fopen to read and then echo display