In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about how to redirect addresses using nginx. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
1. Suppose you want to redirect webroot/static/index.html access to static/index.html
For example, when we access http://192.168.11.210/webroot/static/index.html through a browser, we actually access the static/index.html file under the web directory, and delete the webroot directory and use alias
Location ^ ~ / webroot/ {alias / data/www/web/WebContent/;}
Note:
1. When using alias, be sure to add "/" to the directory name.
2. Alias can specify any name.
3. When using regular matching, alias must capture the content to match and use it at the specified content.
4. Alias can only be in a location block. [/ warning]
Http://192.168.11.210/webroot/test/static/index.html
Location ^ ~ / webroot/test/ {alias / data/www/web/WebContent/;}
This is also possible, the final access to the file is the same as above.
2. Redirect access to webroot/static/index.html to the test directory under the web directory
Location ~ ^ / webroot/ {root/ data/www/web/WebContent/test/;}
Http://192.168.11.210/webroot/static/index.html actually accesses testwebroot/static/index.html under the web directory.
And using root generally redirects the access directory to a directory, but the access path must be in the relocated directory
Pay attention to the difference between distinction and alias
Reprint one:
Access domain name
Www.adc.com/image automatically jumps to www.adc.com/make/image
How to write this?
There are several ways to achieve this requirement:
1. Using Nginx rewrite internal jump to achieve:
Location / image {rewrite ^ / image/ (. *) $/ make/image/$1 last;}
two。 Using alias mapping
Location / image {alias / make/image; # write the absolute path here}
3. Take advantage of root mapping:
Location / image {root / make;}
4. Using permanent 301absolute Jump implementation of nginx
Location / image {rewrite ^ / image/ (. *) $http://www.adc.com/make/image/$1;}
5. Judge the uri implementation
If ($request_uri ~ * ^ (/ image)) {rewrite ^ / image/ (. *) $/ make/image/$1 last;} the above is how to redirect addresses using nginx. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.