nginx ssl pathinfo 伪静态 301 配置文件

  1 server {
  2         listen       80;
  3         root /www/web/test_com/public_html;
  4         server_name test.com test.com;
  5 
  6         if ($host != '***.com')
  7         #注意,这里很严格,if后面要有空格,!=两边都是空格。
  8         {
  9             rewrite ^/(.*)$ https://www.***.com/$1 permanent;
 10         }
 11         if ($scheme = http ) {
 12             return 301 https://www.***.com$request_uri;
 13         }
 14 
 15         index  index.html index.php index.htm;
 16         error_page  400 /errpage/400.html;
 17         error_page  403 /errpage/403.html;
 18         error_page  404 /errpage/404.html;
 19         error_page  503 /errpage/503.html;
 20 
 21         #location ~ .php(.*)$ {
 22         #        fastcgi_pass  unix:/tmp/php-55-cgi.sock;
 23         #        fastcgi_index  index.php;
 24         #        fastcgi_param  SCRIPT_FILENAME  $DOCUMENT_ROOT$fastcgi_script_name;
 25         #        fastcgi_param PATH_INFO $2;
 26         #        include fcgi.conf;
 27         #}
 28 
 29         location ~ .php {
 30                 fastcgi_pass  unix:/tmp/php-55-cgi.sock;
 31                 fastcgi_index  index.php;
 32                 include fcgi.conf;
 33                 set $real_script_name $fastcgi_script_name;
 34                 if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
 35                         set $real_script_name $1;
 36                         set $path_info $2;
 37                 }
 38                 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
 39                 fastcgi_param SCRIPT_NAME $real_script_name;
 40                 fastcgi_param PATH_INFO $path_info;
 41         }
 42 
 43 
 44         location ~ /.ht {
 45                 deny  all;
 46         }
 47         location / {
 48                  try_files $uri $uri/ /?$args;
 49         }
 50 
 51         if (!-e $request_filename) {
 52                  rewrite ^/(.*)$ /index.php/$1 last;
 53                  rewrite  ([a-z_A-Z-s.+0-9]+)/([0-9]+)_([0-9]+).html$ /index.php/Index/shows/catid/$2/id/$3 last;
 54                  rewrite  ([a-z_A-Z-s.+0-9]+).html$ /index.php/Index/jump/catdir/$1 last;
 55                  break;
 56         }
 57 
 58 
 59 }
 60 
 61 server {
 62         listen       443;
 63         root /www/web/test_com/public_html;
 64         ssl                  on;
 65         ssl_certificate      cert/test_com.crt;
 66         ssl_certificate_key  cert/test_com.key;
 67         ssl_prefer_server_ciphers on;
 68         ssl_session_timeout 10m;
 69         ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
 70         ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
 71         server_name test.com test.com;
 72 
 73         if ($host != '***.com')
 74                 #注意,这里很严格,if后面要有空格,!=两边都是空格。
 75         {
 76            rewrite ^/(.*)$ https://www.***.com/$1 permanent;
 77         }
 78         if ($scheme = http ) {
 79             return 301 https://www.***.com$request_uri;
 80         }
 81 
 82         index  index.html index.php index.htm;
 83         error_page  400 /errpage/400.html;
 84         error_page  403 /errpage/403.html;
 85         error_page  404 /errpage/404.html;
 86         error_page  503 /errpage/503.html;
 87         location ~ .php {
 88                 fastcgi_pass  unix:/tmp/php-55-cgi.sock;
 89                 fastcgi_index  index.php;
 90                 include fcgi.conf;
 91                 set $real_script_name $fastcgi_script_name;
 92                 if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
 93                         set $real_script_name $1;
 94                         set $path_info $2;
 95                 }
 96                 fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
 97                 fastcgi_param SCRIPT_NAME $real_script_name;
 98                 fastcgi_param PATH_INFO $path_info;
 99         }
100         location ~ /.ht {
101                 deny  all;
102         }
103         location / {
104                  try_files $uri $uri/ /?$args;
105         }
106 
107         if (!-e $request_filename) {
108            rewrite ^/(.*)$ /index.php/$1 last;
109            rewrite  ([a-z_A-Z-s.+0-9]+)/([0-9]+)_([0-9]+).html$ /index.php/Index/shows/catid/$2/id/$3 last;
110            rewrite  ([a-z_A-Z-s.+0-9]+).html$ /index.php/Index/jump/catdir/$1 last;
111            break;
112         }
113 
114 }
原文地址:https://www.cnblogs.com/handle/p/9876527.html