view xml/tr/docs/http/converting_rewrite_rules.xml @ 593:130fad6dc1b4

Replaced the uses of "url" element with "literal".
author Ruslan Ermilov <ru@nginx.com>
date Thu, 19 Jul 2012 05:17:45 +0000
parents 9913f1d51c07
children
line wrap: on
line source

<!DOCTYPE article SYSTEM "../../../../dtd/article.dtd">

<article name="rewrite kurallarının çevirisi"
         link="/tr/docs/http/converting_rewrite_rules.html"
         lang="tr">

<section name="Ana siteye yönlendirme">

<para>
Paylaşımlı hosting kullananlar genelde her şeyi, sadece Apache&rsquo;nin .htaccess dosyalarını yapılandırarak kullanırlar. Bu dosyada bulunan kuralların çevirisine örnek olarak:

<programlisting>
RewriteCond  %{HTTP_HOST}  example.org
RewriteRule  (.*)          http://www.example.org$1
</programlisting>

kuralı, nginx içerisinde şu şekilde yapılıyor:

<programlisting>
server {
    listen       80;
    server_name  www.example.org  example.org;
    if ($http_host = example.org) {
        rewrite  (.*)  http://www.example.org$1;
    }
    ...
}
</programlisting>
</para>

<para>
Bu yanlış, kullanışsız ve etkisiz bir yoldur. Doğru olan ayrı bir sunucu tanımlaması yapmaktır:

<programlisting>
server {
    listen       80;
    server_name  example.org;
    rewrite   ^  http://www.example.org$request_uri?;
}

server {
    listen       80;
    server_name  www.example.org;
    ...
}
</programlisting>
</para>

</section>


<section>

<para>
Diğer bir örnek ile aşağıdaki geri kalmış mantık yerine (<literal>example.com</literal> olmayan her şey ve <literal>www.example.com</literal> olmayan her şey):

<programlisting>
RewriteCond  %{HTTP_HOST}  !example.com
RewriteCond  %{HTTP_HOST}  !www.example.com
RewriteRule  (.*)          http://www.example.com$1
</programlisting>

sadece <literal>example.com</literal>, <literal>www.example.com</literal> ve diğer her şeyi ayrı ayrı tanımlamalısınız:

<programlisting>
server {
    listen       80;
    server_name  example.com  www.example.com;
    ...
}

server {
    listen       80 default_server;
    server_name  _;
    rewrite   ^  http://example.com$request_uri?;
}
</programlisting>
</para>

</section>


<section id="converting_mongrel_rules"
        name="Mongrel kurallarının çevirisi">

<para>
Tipik Mongrel kuralları:

<programlisting>
DocumentRoot /var/www/myapp.com/current/public

RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ %{DOCUMENT_ROOT}/system/maintenance.html [L]

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*)$ $1 [QSA,L]

RewriteCond %{REQUEST_FILENAME}/index.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]

RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^(.*)$ $1/index.html [QSA,L]

RewriteRule ^/(.*)$ balancer://mongrel_cluster%{REQUEST_URI} [P,QSA,L]
</programlisting>

şu şekilde dönüştürülmelidir:

<programlisting>
location / {
    root       /var/www/myapp.com/current/public;

    try_files  /system/maintenance.html
               $uri  $uri/index.html $uri.html
               @mongrel;
}

location @mongrel {
    proxy_pass  http://mongrel;
}
</programlisting>
</para>

</section>

</article>