T086ѧϰ�� | վ��ѧԺ | �����ĵ� | ���� | Ъ���� | IP��ַ��ѯ | �������� | ���ջ��� | �����ֵ� | ���ù��� | ������Ϣ��ѯ

Nginx Location �﷨������������

�� ���� ����ʱ�䣺2010-07-21 | ���壺�� �� С��
[����]һ������Nginx�Ƕ���˹�˱�д��ʮ����������HTTP������,Nginx�����ķ���Ϊ“engine X”�� ��һ�������ܵ�HTTP�ͷ���������������ͬʱҲ��һ��IMAP/POP3/SMTP ������������ ����Location�﷨�﷨��location...

һ������Nginx�Ƕ���˹�˱�д��ʮ����������HTTP������,Nginx�����ķ���Ϊ“engine X”�� ��һ�������ܵ�HTTP�ͷ���������������ͬʱҲ��һ��IMAP/POP3/SMTP ������������
����Location�﷨�﷨��location [=|~|~*|^~] /uri/ { … }
ע��
1��~   Ϊ���ִ�Сдƥ��
2��~* Ϊ�����ִ�Сдƥ��
3��!~��!~*�ֱ�Ϊ���ִ�Сд��ƥ���������ִ�Сд
��ƥ��
ʾ��һ��
location  / {
}
ƥ���κβ�ѯ����Ϊ������������ / ��ͷ��������������ʽ���򽫱����ȺͲ�ѯƥ�䡣
ʾ������
location =/ {}
����ƥ��/

ʾ������
location ~* \.(gif|jpg|jpeg)$ ��
rewrite \.(gif|jpg)$ /logo.png;
��
ע�������ִ�Сдƥ���κ���gif��jpg��jpeg��β���ļ�

����ReWrite�﷨
last - �����϶�������Flag��
break - ��ֹRewirte�����ڼ���ƥ��
redirect - ������ʱ�ض�����HTTP״̬302
permanent - ���������ض�����HTTP״̬301

1�������ǿ��������жϵı���ʽ��
-f��!-f�����ж��Ƿ������ļ�
-d��!-d�����ж��Ƿ�����Ŀ¼
-e��!-e�����ж��Ƿ������ļ���Ŀ¼
-x��!-x�����ж��ļ��Ƿ���ִ��
2�������ǿ��������жϵ�ȫ�ֱ���
����http://localhost:88/test1/test2/test.php
$host��localhost
$server_port��88
$request_uri��
http://localhost:88/test1/test2/test.php
$document_uri��/test1/test2/test.php
$document_root��D:\nginx/html
$request_filename��D:\nginx/html/test1/test2/test.php

�ġ�Redirect�﷨
    server {
    listen 80;
    server_name start.igrow.cn;
    index index.html index.php;
    root html;
    if ($http_host !~ "^www\.itlearner\.com$ {
         rewrite ^(.*)
http://www.itlearner.com$1 redirect;
    }
    }

�塢������location ~* \.(gif|jpg|swf)$ {
  valid_referers none blocked start.igrow.cn sta.igrow.cn;
  if ($invalid_referer) {
  rewrite ^/
http://$host/logo.png;
  }
}

���������ļ��������ù���ʱ��
location ~* \.(js|css|jpg|jpeg|gif|png|swf)$ {
if (-f $request_filename) {
   expires    1h;
   break;
}
}

�ߡ���ֹ����ij��Ŀ¼
location ~* \.(txt|doc)${
   
  root /data/www/wwwroot/linuxtone/test;
   
deny all;
}
 

++ һЩ���õ�ȫ�ֱ���
$args
$content_length
$content_type
$document_root
$document_uri
$host
$http_user_agent
$http_cookie
$limit_rate
$request_body_file
$request_method
$remote_addr
$remote_port
$remote_user
$request_filename
$request_uri
$query_string
$scheme
$server_protocol
$server_addr
$server_name
$server_port
$uri

  • ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
  • �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
  • ��
������ѯ Health Check Gulangyu
© 2017 T086ѧϰ�� - T086.com(ԭitlearner.com)
RunTime:6.01ms QueryTime:7