Mercurial > hg > nginx-site
comparison xml/en/docs/http/converting_rewrite_rules.xml @ 107:ee725af08951
Two unrelated changes were erroneously committed simultaneously:
- Making the rest of HTML valid.
- Updating the "Converting rewrite rules" howto examples to utilize
the new power of the "return" directive.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Wed, 19 Oct 2011 12:39:11 +0000 |
parents | d1e8781b9c5f |
children | 49443032011c |
comparison
equal
deleted
inserted
replaced
106:56457a474903 | 107:ee725af08951 |
---|---|
30 } | 30 } |
31 </programlisting> | 31 </programlisting> |
32 </para> | 32 </para> |
33 | 33 |
34 <para> | 34 <para> |
35 This is a wrong, cumbersome, and ineffective way. | 35 This is a wrong, cumbersome, and ineffective way. |
36 The right way is to define a separate server for <url>nginx.org</url>: | 36 The right way is to define a separate server for <url>nginx.org</url>: |
37 | 37 |
38 <programlisting> | 38 <programlisting> |
39 server { | 39 server { |
40 listen 80; | 40 listen 80; |
41 server_name nginx.org; | 41 server_name nginx.org; |
42 rewrite ^ http://www.nginx.org$request_uri?; | 42 return 301 http://www.nginx.org$request_uri; |
43 } | 43 } |
44 | 44 |
45 server { | 45 server { |
46 listen 80; | 46 listen 80; |
47 server_name www.nginx.org; | 47 server_name www.nginx.org; |
48 ... | 48 ... |
49 } | 49 } |
50 </programlisting> | 50 </programlisting> |
51 | |
52 <note> | |
53 On versions prior to 0.9.1, redirects can be made with: | |
54 <programlisting> | |
55 rewrite ^ http://www.nginx.org$request_uri?; | |
56 </programlisting> | |
57 </note> | |
58 | |
51 </para> | 59 </para> |
52 | 60 |
53 </section> | 61 </section> |
54 | 62 |
55 | 63 |
70 and “everything else”: | 78 and “everything else”: |
71 | 79 |
72 <programlisting> | 80 <programlisting> |
73 server { | 81 server { |
74 listen 80; | 82 listen 80; |
75 server_name nginx.com www.nginx.com; | 83 server_name nginx.com www.nginx.com; |
76 ... | 84 ... |
77 } | 85 } |
78 | 86 |
79 server { | 87 server { |
80 listen 80 default_server; | 88 listen 80 default_server; |
81 server_name _; | 89 server_name _; |
82 rewrite ^ http://nginx.com$request_uri?; | 90 return 301 http://nginx.com$request_uri; |
83 } | 91 } |
84 </programlisting> | 92 </programlisting> |
93 | |
94 <note> | |
95 On versions prior to 0.9.1, redirects can be made with: | |
96 <programlisting> | |
97 rewrite ^ http://nginx.com$request_uri?; | |
98 </programlisting> | |
99 </note> | |
100 | |
85 </para> | 101 </para> |
86 | 102 |
87 </section> | 103 </section> |
88 | 104 |
89 | 105 |