šŸŒ Mapping a URL to another path in Nginx ā€“ IT is good

šŸŒ Mapping a URL to another path in Nginx ā€“ IT is good

Sometimes we need to map a URL to another directory path on the file system.

Nginx users can achieve this with the “location” block in the config file.

The location block specifies a regular expression for the URL that the browser is requesting.

In the location block, we can specify the path to the file system using the ‘root’ or ‘alias’ option.

How to map an Nginx directory to a specific URL?

You can use the alias directive inside a location block, like so:

In the above configuration, the main site is set to the /var/www/example.com directory.

But a URL starting with ā€œ/staticā€ will be served from the ā€œ/var/content/staticā€ directory.

For example, the URL would point to the /var/www/static/file.txt file.

see also:

Share this article:

fb-share-icon

Section: Web
Tags: nginx



Web,Nginx,WEB,

#Mapping #URL #path #Nginx #good

Leave a Comment

Your email address will not be published. Required fields are marked *