1

i have this URI /orls/myservice/f?p=4550 and the following location

location ~ "^/(.+)/myservice/f?p=(.+)$" { ..... } 

nginx is returning a 404 not found. the problem might come from the ? so i tried \? buit i'm still getting the same error. Can anyone help ?

1
  • what exactly you need to match from here: /orls/myservice/f?p=4550 Commented Apr 8, 2015 at 16:36

3 Answers 3

2

The location match does not consider the query string:

Note that locations of all types test only a URI part of request line without arguments. This is done because arguments in the query string may be given in several ways [...] 

http://nginx.org/en/docs/http/request_processing.html

0

Try also to escape the / character

http://regexr.com/3apga

1
  • It's not working nginx does not seem to support ? querry. Commented Apr 8, 2015 at 16:28
-1

You need to escape slashes and question mark, like this:

location ~ "^\/(.+)\/myservice\/f\?p=(.+)$" { ..... } 

This will match first folder and p arg.

1 = orls 2 = 4550 
2
  • This does not make sense, as the location is not compared against the part after ?. "locations of all types test only a URI part of request line without arguments" Source: nginx.org/en/docs/http/request_processing.html Commented Feb 24, 2022 at 14:59
  • I don't remember this answer now, as it was long time ago, checked in online regexp and this pattern "^\/(.+)\/myservice\/f\?p=(.+)$" is matching two groups orls and 4550, but the solution to this problem could be related to nginx, cant test and cant help right now. Commented Mar 19, 2022 at 18:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.