In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
1. Open rewrite log
Rewrite_log on; # http segment added
Error_log logs/xxxerror.log notice; # is lowering the error log level
two。 Jump to domain name location / {rewrite / https://www.baidu.com;}
# indicates that as long as you access this domain name, you can directly jump to baidu.
# viewing the log shows that the record accesses "111.com" with "/" and jumps to "baidu"
Modify the code
Location / rewrite/ {rewrite/ https://www.baidu.com;}
# indicates that the folder will jump only if the domain name is followed by "/ rewrite/" (only / rewrite/ will trigger the jump, and other folders will be forwarded normally)
The figure below is as follows
# I used "www.111.com/rewrite/123.com" access to jump
3. Use regular jumps
Example 1
Www.111.com/111/index.html jumps to www.111.com/222/index.html
Location / {rewrite ^ / 111 / (. *) $/ 222 Universe 1;}
# "^" means root, which means www.111.com. (. *) matches all meanings, followed by "$1" call.
# Log, you can see that / 111/index.html jumps to / 222/index.html
The 4.rewrite instruction last terminates the processing of the received URI in this location block and processes the URI rewritten here as a new URI using other location. (go to the first location match) break continues to execute the URI rewritten here as a new URI in the current location, and does not transfer the new URI to another location. (continue matching from the current location) redirect returns the rewritten URI to a client with a status code of 302, indicating temporary redirection, which is mainly used when the replacement string does not start with "http://","https://"" or "$scheme". Permanent returns the rewritten URI to the client with a status code of 301, indicating permanent redirection. What is the use of permanent jump and what is temporary jump? Let's give an example: if there is a url,/a. If it is configured as rewrite "/ a" http://test.html" redirect;, it means that the jump is a temporary jump, and if a web crawler climbs this link, it will not update its url database. But if configured as permanet, the crawler updates its url database, updating / a to http://test.html. This is the difference between a temporary jump and a permanent jump. The difference between break and last tests location / 222 / {rewrite ^ / 222 / (. *) / 333 break; 1;} location / {rewrite ^ / 111 / (. *) / 222 Universe 1 break;}
# with the above configuration, the final url will be output to the "222nd" folder. If the break is replaced with last, the 111in url will be replaced with 222to continue matching from the first location, so the final output url is "333".
#
5.if judgment plus call variable jump
Example 1
If ($server_port = 80) {rewrite ^ (. *) $https://$host$1 permanent;}
# configure in the http segment, which means that if the visitor is accessed on port 80, the redirection will be performed. Match the url after the root and rewrite the domain name "+" matching url accessed by https://"
Example 2
If (!-f $request_filename) {rewrite (. *) http://$host/bucunzai.html;}
# configure in the location section, "!-f $request_filename" means to detect whether there is a problem with the url request locally, and forward it to "buzunzai.html" if the page file does not exist.
Instance 3 www.111.com/jpg-aaa-bbb-ccc.html = > www.111.com/jpg/aaa/bbb/ccc/jpg_ccc.html
Location / {rewrite ^ / (. *)-(. *). Html$ / $1/$2/$3/$4/$1_$4.html;}
Example 4 completes www
If ($host = "111.com") {rewrite ^ (. *) $http://www.111.com$1 last;}
# in the http section, the "$host" variable is the domain name in url if accessed with "111.com/123.html"
"111.com", if "www.111.com/233.html" means "www.111.com"
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.