Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

in nginx config, what is the meaning of caret ^ by itself?

A bit down on this nginx config reference page you'll see:

rewrite ^ http://example.com$request_uri? permanent;

What is the meaning of ^ above?

like image 965
Nikita Avatar asked Jan 20 '12 04:01

Nikita


People also ask

How do I know if nginx config is correct?

Through a simple command you can verify the status of the Nginx configuration file: $ sudo systemctl config nginx The output will show if the configuration file is correct or, if it is not, it will show the file and the line where the problem is.

What is the default nginx config?

By default, the configuration file is named nginx. conf and placed in the directory /usr/local/nginx/conf , /etc/nginx , or /usr/local/etc/nginx .

How does nginx config work?

Nginx uses an event-based connection processing model, so the directives defined within this context determine how worker processes should handle connections. Mainly, directives found here are used to either select the connection processing technique to use, or to modify the way these methods are implemented.

How does nginx location work?

The location directive within NGINX server block allows to route request to correct location within the file system. The directive is used to tell NGINX where to look for a resource by including files and folders while matching a location block against an URL.


1 Answers

For rewrite, the first argument is the match pattern and only applies to the path portion of the url, not the domain. In regular expressions, ^ matches the beginning of the input. For example, ^/photos/.*$ would match paths beginning in '/photos/'. By itself, ^ is a shortcut for all paths (since they all have a beginning).

like image 104
Kylos Avatar answered Sep 27 '22 19:09

Kylos