server
{
listen 80;
server_name pl.sourcingmap.com;
index index.html index.htm index.php;
root /export/wwwsourcingmap;
if (-f $request_filename/index.html)
{
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.htm)
{
rewrite (.*) $1/index.htm break;
}
if (-f $request_filename/index.php)
{
rewrite (.*) $1/index.php break;
}
if ($geo = 'CN' )
{
rewrite (.*) /error403.html break;
}
error_page 404 /error_info.php;
error_page 403 /error403.html;
rewrite ^/\\$ /index.php;
rewrite ^/card$ /welcome.html;
rewrite ^(.*)iphone-skin-case-c-983_1389.html$ /iphone-cases-c-983_1389.html[R=301,L];
rewrite ^(.*)pda-laptop-batteries-c-1355_1446.html$ /pda-laptop-batteries-c-987_1446.html[R=301,L];
rewrite ^(.*)laptop-adapters-c-1355_1758.html$ /laptop-adapters-c-987_1758.html[R=301,L];
rewrite ^(.*)laptop-accessories-c-1355_1546.html$ /laptop-accessories-c-987_1546.html[R=301,L];
rewrite ^(.*)laptop-keyboard-cases-c-987_1355_1796.html$ /laptop-keyboard-cases-c-987_1796.html[R=301,L];
rewrite ^(.*)laptop-carrying-bags-c-1355_1794.html$ /laptop-carrying-bags-c-987_1794.html[R=301,L];
rewrite ^(.*)-p-(.*).html$ "/product_info.php?products_id=$2&%{QUERY_STRING}";
rewrite ^(.*)-p-(.*)/osCsid/(.*) /product_info.php?products_id=$2;
rewrite ^(.*)-c-(.*).html$ "/index.php?cPath=$2&%{QUERY_STRING}";
rewrite ^(.*)-m-([0-9]+).html$ "/index.php?manufacturers_id=$2&%{QUERY_STRING}";
rewrite ^(.*)-pi-([0-9]+).html$ "/popup_image.php?pID=$2&%{QUERY_STRING}";
rewrite ^(.*)-t-([0-9]+).html$ "/articles.php?tPath=$2&%{QUERY_STRING}";
rewrite ^(.*)-a-([0-9]+).html$ "/article_info.php?articles_id=$2&%{QUERY_STRING}";
rewrite ^(.*)-pr-([0-9]+).html$ "/product_reviews.php?products_id=$2&%{QUERY_STRING}";
rewrite ^(.*)-pri-([0-9]+).html$ "/product_reviews_info.php?products_id=$2&%{QUERY_STRING}";
rewrite ^(.*)-i-([0-9]+).html$ "/information.php?info_id=$2&%{QUERY_STRING}";
rewrite ^/nfl_gear_products.html$ /advanced_search_result.php?searchbar=1&keywords=NFL+Gear&searchType=all[R=301,L];
rewrite index.php/cPath/(.+) /index.php?cPath=$1;
rewrite product_info.php/products_id/(.+) /product_info.php?products_id=$1;
rewrite product_reviews_info.php/products_id/(.+)/reviews_id/(.+) /product_reviews_info.php?products_id=$1&reviews_id=$2;
rewrite product_info.php/cPath/(.+)/products_id/(.+) /product_info.php?cPath=$1&products_id=$2;
location ~ .*\.php?$
{
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /export/wwwsourcingmap/$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
# location / {
# deny from CN,HK;
# allow from all;
# }
#location /NginxStatus
#{
# stub_status on;
# access_log off;
#}
location ~* ^/admin/{
root /export/wwwsourcingmap/admin;
auth_basic "Restricted";
auth_basic_user_file "/usr/local/nginx/conf/htpasswd";
}
location = /_.gif {
empty_gif;
}
location /dynamic_request {
set $memcached_key $uri;
if ($args ~* format=json) { rewrite ^/dynamic_request/?(.*)$ /dynamic_request.js$1 break; }
if ($args ~* format=xml) { rewrite ^/dynamic_request/?(.*)$ /dynamic_request.sml$1 break; }
memcached_pass 127.0.0.1:11211;
default_type text/html;
memcached_buffer_size 8096;
error_page 404 = @dynamic_request;
}
# location ~/\.ht {
# deny all;
# }
}
红色部分为按国家区码限制访问的代码。按三楼的规则设置的话,连二级联接都没有效果了