Nginx下简单的域名重定向

相同域名的域名重定向
http://www.localhost.com --> https://www.localhost.com
方法一:

server {
        listen       80;
        server_name  www.localhost.com localhost.com;
       rewrite  "^/(.*)$"  https://${host}/$1 permanent;
}

方法二:

server {
        listen       80;
        server_name  www.localhost.com localhost.com;
        return 301 https://$host$request_uri;
}

PS:

$server_name 只能匹配第一个域名
$host 可以匹配到对应域名

ThinkPHP伪静态


        if (!-e $request_filename) {
           rewrite  ^/(.*)$  /index.php/$1  last;
           break;
        }

猜你喜欢

转载自blog.csdn.net/wangshui898/article/details/82019100
今日推荐