Apache and nginx rewrite rule problems.

Source: Internet
Author: User

Although both Apache and Nginx Rewirte modules are declared based on Perl, the actual use is still different, especially nginx.

In Apache, use global variables%{in the httpd.conf file of the server global configuration ...} The judgment is not secure, and when I use%{request_filename} to determine whether the request is a file, there is an error. Whether the request matches the file or not, it returns No. The reasons for this are indicated in the manual:

If used in per-server context (i.e., before the request was mapped to the filesystem) Script_filename and Request_ FILENAME cannot contain the full local filesystem path since the path was unknown at this stage of processing. Both variables would initially contain the value of Request_uri in this case. In order to obtain the full local filesystem path of the "request in Per-server context", use an url-based look-ahead %{LA-U:REQUEST_FILENAME} To determine the final value of Request_filename.

It says that, if used in the server configuration environment, the Script_filename and Request_filename variables cannot contain the entire file system path, because these paths are unknown at this processing stage. At this point, these two variables are just the initial values of the Request_uri variable. In order to get the system path, you can use a URL-based variable%{la-u:request_filename} in front of the detection.

Nginx has a very strange phenomenon, in the regular midpoint (.) If there is no regular semantics of the statement in parallel, it is a simple point, if you use \ Escape instead of error, because it is the \. As two characters. For example:

last;

The point number of the replaced part does not need to be escaped. But if this is the case:

last;

Need, do not know other types is this?!

Apache and nginx rewrite rule problems.

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.