代码之家  ›  专栏  ›  技术社区  ›  Ben Chiciudean

Wordpress Nginx Permalink从普通到postname

  •  0
  • Ben Chiciudean  · 技术社区  · 7 年前

    我正在努力改变 http://sitename/?p=123 http://sitename/postname 使用重写规则,但未找到错误404。这是我的nginx服务器块代码:

    server {
    
            listen 80;
            listen 443 ssl;
    
            root /var/www/sitename/html;
            index index.php index.html index.htm;
    
            server_name sitename www.sitename;
            client_max_body_size 10M;
    
            # Certificates handled by CertBot
    
            location ~ \.php$ {
                    try_files $uri =404;
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                    fastcgi_index index.php;
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    include fastcgi_params;
            }
    
            location / {
                    server_name sitename www.sitename;
                    # First attempt to serve request as file, then
                    # as directory, then fall back to displaying a 404.
                    # try_files $uri $uri/ /index.php$is_args$args;
                    # rewrite ^ http://$server_name$request_uri permanent;
                    rewrite ^/(.*)$ http://$server_name/$1 permanent;
                    # Uncomment to enable naxsi on this location
                    # include /etc/nginx/naxsi.rules
                    # root /data/www;
                    # index index.html index.htm;
            }
    }
    

    我想使用重写,所以我将前端的https重定向到http和wp admin,wp登录为https,由Wordpress处理。

    我怎样才能修复它?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Ben Chiciudean    7 年前

    使用443 listen创建了一个单独的类似服务器块。包括证书行并从443块中删除位置。

    推荐文章