不言不语

您现在的位置是: 首页 >  PHP

PHP

网站Nginx设置301跳转方法

2020-10-22PHP
网站中怎么设置Nginx设置301跳转方法详细介绍


以lygamtsl.com为例!



server {
        listen       80;
        server_name  lygamtsl.com;

      if ($host != 'lygamtsl.com;' ) {
        rewrite ^/(.*)$ http://www.lygamtsl.com/$1 permanent;
    }

   
    }

注:301跳转到www.lygamtsl.com


server {
        listen       80;
        server_name  www.lygamtsl.com;
    client_max_body_size 1000M;
        root    "C:/phpStudy/PHPTutorial/WWW/lianyun/public/";
        location / {
            index  index.html index.htm index.php l.php ;
           autoindex  off;
   if (!-e $request_filename) {
   rewrite  ^(.*)$  /index.php?s=/$1  last;
   break;
    }

        }

 
      
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    
        location ~ \.php(.*)$  {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }

   
    }


php中nginx配置,其他配置自行百度!

文章评论