In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
Nginx how to achieve redirection, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Detailed explanation of the whole process of Nginx Rewrite flag tag: flag tag: last is equivalent to the [L] tag in Apache It means that the rewrite break termination match is completed, and the following rule is no longer matched. redirect returns 302 temporary redirect address bar will display the jump address permanent return 301 permanent redirection address bar will display the jump address such as the following setting nginx redirects files under one directory to another directory $2 corresponds to the corresponding string in the second parenthesis (. *): location / download/ { rewrite ^ (/ download/.*) / m / (. *)\.. * $1/nginx-rewrite/$2.gz break The IF condition judgment of } nginx redirection can be judged by nginx's IF condition in both server and location cases, and the conditions can be as follows: regular expressions such as: matching judgment ~ for case-sensitive matching;! ~ for case-sensitive mismatch ~ * for case-insensitive matching ! ~ for case-insensitive mismatches, for example, set nginx to redirect users' use of ie to / nginx-ie directory: if ($http_user_agent ~ MSIE) {comment: _ _ (MSIE-> ie browser kernel) _ _ rewrite ^ (. *) $/ nginx-ie/$1 break } File and directory judgment-f and!-f determine whether there are files-d and!-d determine whether there are directories-e and!-e to determine whether there are files or directories-x and!-x to determine whether files are executable, for example, to set nginx to redirect when files and directories do not exist: if (!-e $request_filename) {proxy_pass http://127.0.0.1/; } return returns http code, such as setting nginx hotlink protection: location ~ *\. (gif | jpg | png | swf | flv) ${valid_referers none blocked http://www.jefflei.com/ http://www.leizhenfang.com/; if ($invalid_referer) {return 404 }} set sets nginx variable (to be continued) 301Redirect method performs 301redirection, merging www. Jefflei.com and jefflei.com, and merging previous domain names as well. There are two ways to implement this. The first is to determine the nginx core variable host (the old version is http_host): server {server_name www.jefflei.com jefflei.com; if ($host! = 'www.jefflei.com') {rewrite ^ / (. *) $http://www.jefflei.com/$1 permanent;}.}
The second method:
Server {server_name jefflei.com; rewrite ^ / (. *) http://www.jefflei.com/$1 permanent;} tested the first method, ok, of which permanent is the key, as described in the nginx redirection rules for details. Last-basically use this Flag. break-aborts Rewirte, no longer matches redirect-returns temporary redirected HTTP status 302 permanent-returns permanent redirected HTTP status 301. Now you can check the results. Here you can see the returned HTTP header information: http://www.seoconsultants.com/tools/headers.asp the second method did not test successfully. Test whether the input is directed successfully: / usr/local/nginx/sbin/nginx-t hint: the configuration file / usr/local/nginx/conf/nginx.conf syntax is ok configuration file / usr/local/nginx/conf/nginx.conf test is successful test succeeded ~ restart nginx~ input instruction ~ / usr/local/nginx/sbin/nginx-s reload restart and test ~ whether the setting is completed successfully! Input instruction ~ curl-I imcat.tk will output: HTTP/1.1 301Moved Permanently Server: nginx/0.7.65 Date: Tue, 03 Aug 2010 01:12:37 GMT Content-Type: text/html Content-Length: 185 Connection: keep-alive Location: http://qinfy.net/ will it help you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.