Nginx location regular match

Source: Internet
Author: User
Nginx location regular match Problem reply discussion (solution)

Rewrite ^/([A-D]) ([a-zA-Z0-9] {10 })/? $/Index. php? A = $1 & B = $2 last;

Rewrite ^/([A-D]) ([a-zA-Z0-9] {10 })/? $/Index. php? A = $1 & B = $2 last;



It is matched in location and matched to forward

The following error is reported and cannot be started.
location ^/([A-D])([a-zA-Z0-9]{10})/?$ {proxy_pass http://127.0.0.1:88/;proxy_redirect off;proxy_set_header Host localhost2;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Referer $http_referer;proxy_set_header Cookie $http_cookie;proxy_connect_timeout 60;proxy_read_timeout 600;proxy_send_timeout 600;}

Location ~ ^/([A-D]) ([a-zA-Z0-9] {10 })/? $

Add ~ That is, regular expression matching.

What is the error message?
Paste it ....

Location ~ ^/([A-D]) ([a-zA-Z0-9] {10 })/? $

Add ~ That is, regular expression matching.



Or an error is reported, but it cannot be started.

Starting nginx: [emerg] pcre_compile () failed: missing) in "^/([A-D]) ([a-zA-Z0-9]"

What is the error message?
Paste it ....



Starting nginx: [emerg] pcre_compile () failed: missing) in "^/([A-D]) ([a-zA-Z0-9]"

Missing) in "^/([A-D]) ([a-zA-Z0-9]"
It is truncated on the braces. it is estimated that it is confused with the braces of the subsequent code segments. do you need to escape them? Or you can replace {10} with + directly.
I have never done this... you can see what special symbols need to be processed.

Missing) in "^/([A-D]) ([a-zA-Z0-9]"
It is truncated on the braces. it is estimated that it is confused with the braces of the subsequent code segments. do you need to escape them? Or you can replace {10} with + directly.
I have never done this... you can see what special symbols need to be processed.



No.

Location ^/([A-D]) ([a-zA-Z0-9] + )/? $ {}
I can start nginx on my side.

Location ^/([A-D]) ([a-zA-Z0-9] + )/? $ {}
I can start nginx on my side.



You are right. the code below my location is wrong.

Finally, I changed it "~ /[A-D] [a-zA-Z0-9] {10} $"

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.