How to prevent users from entering a page manually

Source: Internet
Author: User
How to prevent users from entering a page manually? The root directory of the website contains the INDEX. PRIVATE. PHP page. Currently, I only allow it to be called by client programs and cannot be manually accessed by users (for example, http: // 127.0.0.0/private. php), how to set it ?, How can I prevent users from entering a page manually?
The root directory of the website contains the INDEX. PRIVATE. PHP page. Currently, I only allow it to be called by client programs and cannot be manually accessed by users (for example, http: // 127.0.0.0/private. php), how to set it?

------ Solution --------------------
Determine the source request address or obtain the last request address

$ _ SERVER ['http _ referer'];

If this is not the case, you can use js to implement it.
------ Solution --------------------
The optimal solution is $ _ SERVER ['http _ referer']; source monitoring
The other method is to set session permission authentication. a common user session jumps or returns 404 headers.
Users can use get or post parameters for authentication. it is also difficult for users who do not know the rules to make breakthroughs.
------ Solution --------------------
You don't have to use session.
You are in PRIVATE. Php also sets a variable.
For example
If ($ flag = 'value ')
...
Else
Exit ;...

When your client calls it, pass this value to this page to get its value.

You can set this value by yourself.
------ Solution --------------------
The client transmits encrypted data to the server for decryption and verification

I don't need to talk about the rest.
------ Solution --------------------
1. after the client is installed, generate your own public/private key and submit the GUID and public key through the custom protocol protected by HTTPS.

2. in the future, when the client connects to the server, the private key will be used to encrypt the GUID and then be submitted together with the GUID, the server selects the corresponding public key based on the GUID to decrypt and verify the GUID. if The GUID is successfully decrypted, the client is considered normal to issue the COOKIE used for SESSION.

In fact, the key is two points:

1. after the client is installed, the client connects to the server for the first time through HTTPS. if the server is considered to be fraudulent, the client can ask the CA to verify the certificate sent from the server. Otherwise, the client can directly trust the server certificate, the customer submits the customer's public/private key through the public/private key encryption and exchange of symmetric keys.

2. in fact, it is the configuration of the trust relationship under HTTPS protection. There should be several people who have played SCP/SSH.

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.