Currently, many PHP programs use url rewriting technology to optimize URLs. But sometimes we need to distinguish the default url request from the url rewrite request in PHP. How can this problem be solved? My solution is to find the answer in the constant $ _ SERVER. In different servers, $ _ SERVER will have an index to record the path before rewriting the request access rewrite,
Currently, many PHP programs use url rewriting technology to optimize URLs. But sometimes we need to distinguish the default url request from the url rewrite request in PHP. How can this problem be solved? My solution is to find the answer in the constant $ _ SERVER. In different servers, $ _ SERVER will have an index to record the path before rewriting the request access rewrite,
Currently, many PHP programs use url rewriting technology to optimize URLs. But sometimes we need to distinguish the default url request from the url rewrite request in PHP. How can this problem be solved?
My solution is to find the answer in the constant $ _ SERVER. In different servers, $ _ SERVER will have an index to record the path before rewriting the request access rewrite, indexes of some mainstream servers are as follows:
IIS7 + Rewrite Module-> $ _ SERVER ['HTTP _ X_ORIGINAL_URL ']
IIS6 + ISAPI Rewite-> $ _ SERVER ['HTTP _ X_REWRITE_URL ']
Apache2-> $ _ SERVER ['request _ url'] or $ _ SERVER ['redirect _ url']
Nginx-> $ _ SERVER ['request _ URI ']
The result is that you only need to determine the parameters HTTP_X_ORIGINAL_URL, HTTP_X_REWRITE_URL, REQUEST_URI, and REDIRECT_URL. Then, you can determine in PHP that the request url is from the address that is rewritten or in the default format.
Note: url rewriting