Can PHP control the reading of a folder?

Source: Internet
Author: User
Tags echo display
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.