How can a static page be defined as a restricted page?

Source: Internet
Author: User
Tags http authentication
How can a static page be defined as a restricted page? When I look at identity authentication, the book mentions the concept of HTTP authentication, that is, if a user wants to read a protected resource, the server will return a 401, in this way, the browser will pop up a login window based on 401. This process is well simulated in PHP, such as: & nbsp; 3. how can a static page be defined as a restricted page?
When I look at identity authentication, the book mentions the concept of HTTP authentication, that is, if a user wants to read a protected resource, the server will return a 401, in this way, the browser will pop up a login window based on 401. This process is well simulated in PHP, for example:
3 $ username = 'default ';
4 $ password = '000000 ';
5 // when you log on to this page, you must call the verification box because the USER and PW are not set.
6 if (! Isset ($ _ SERVER ['php _ AUTH_USER ']) |! Isset ($ _ SERVER ['php _ AUTH_PW '])
7 | $ _ SERVER ['php _ AUTH_USER ']! = $ Username | $ _ SERVER ['php _ AUTH_PW ']! = $ Password ){
8 // set this page to unauthorized access
9 header ('http/1.1 401 unauthorized ');
10 // call the verification box for logon verification
11 header ('www-Authenticate: Basic realm = "logon authentication "');
12 exit ('verification failed !!! ');
13}

I would like to ask, if there is no way to write code for a static page, how can I define a page as protected?

------ Solution --------------------
There is basically nothing to do with your above verification method. the experience is poor and the security is not high...
To control a page, you can use the include method after determining the permission or read the page content output.
The page can be placed outside the web directory.

Protection is done on the server unless you are developing cs.

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.