comparison xml/he/docs/http/converting_rewrite_rules.xml @ 0:61e04fc01027

Initial import of the nginx.org website.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 11 Aug 2011 12:19:13 +0000
parents
children 9d544687d02c
comparison
equal deleted inserted replaced
-1:000000000000 0:61e04fc01027
1 <!DOCTYPE digest SYSTEM "../../../../dtd/article.dtd">
2
3 <article title="המרת כללי rewrite"
4 link="/he/docs/http/converting_rewrite_rules.html"
5 lang="he"
6 author="Igor Sysoev"
7 translator="מבזקים.נט">
8
9 <section title="הפנייה לאתר ראשי">
10
11 <para>
12 משתמשים שבמהלך חיי האירוח המשותף נהגו להגדיר <i>הכל</i> באמצעות
13 שימוש <i>רק</i> בקובצי htaccess. של Apache, יתרגמו בדרך כלל את
14 הכללים הבאים:
15
16 <programlisting>
17 RewriteCond %{HTTP_HOST} nginx.org
18 RewriteRule (.*) http://www.nginx.org$1
19 </programlisting>
20
21 למשהו כזה:
22
23 <programlisting>
24 server {
25 listen 80;
26 server_name www.nginx.org nginx.org;
27 if ($http_host = nginx.org) {
28 rewrite (.*) http://www.nginx.org$1;
29 }
30 ...
31 }
32 </programlisting>
33 </para>
34
35 <para>
36 צורה זו היא שגוייה, מסובכת, ולא יעילה.
37 הדרך הנכונה היא להגדיר שרת נפרד עבור <url>nginx.org</url>:
38
39 <programlisting>
40 server {
41 listen 80;
42 server_name nginx.org;
43 rewrite ^ http://www.nginx.org$request_uri?;
44 }
45
46 server {
47 listen 80;
48 server_name www.nginx.org;
49 ...
50 }
51 </programlisting>
52 </para>
53
54 </section>
55
56
57 <section>
58
59 <para>
60 דוגמה נוספת, במקום הגיון הפוך: כל מה שהוא לא
61 <url>nginx.com</url> וגם לא <url>www.nginx.com</url>:
62
63 <programlisting>
64 RewriteCond %{HTTP_HOST} !nginx.com
65 RewriteCond %{HTTP_HOST} !www.nginx.com
66 RewriteRule (.*) http://www.nginx.com$1
67 </programlisting>
68
69 עלייך רק להגדיר את <url>nginx.com</url>, <url>www.nginx.com</url>,
70 וכל דבר אחר:
71
72 <programlisting>
73 server {
74 listen 80;
75 server_name nginx.org www.nginx.org;
76 ...
77 }
78
79 server {
80 listen 80 default_server;
81 server_name _;
82 rewrite ^ http://nginx.org$request_uri?;
83 }
84 </programlisting>
85 </para>
86
87 </section>
88
89
90 <section name="converting_mongrel_rules"
91 title="המרת כללי Mongrel">
92
93 <para>
94 כללי Mongrel טיפוסיים:
95
96 <programlisting>
97 DocumentRoot /var/www/myapp.com/current/public
98
99 RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
100 RewriteCond %{SCRIPT_FILENAME} !maintenance.html
101 RewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L]
102
103 RewriteCond %{REQUEST_FILENAME} -f
104 RewriteRule ^(.*)$ $1 [QSA,L]
105
106 RewriteCond %{REQUEST_FILENAME}/index.html -f
107 RewriteRule ^(.*)$ $1/index.html [QSA,L]
108
109 RewriteCond %{REQUEST_FILENAME}.html -f
110 RewriteRule ^(.*)$ $1/index.html [QSA,L]
111
112 RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
113 </programlisting>
114
115 יש להמיר כך
116
117 <programlisting>
118 location / {
119 root /var/www/myapp.com/current/public;
120
121 try_files /system/maintenance.html
122 $uri $uri/index.html $uri.html
123 @mongrel;
124 }
125
126 location @mongrel {
127 proxy_pass http://mongrel;
128 }
129 </programlisting>
130 </para>
131
132 </section>
133
134 </article>