繁体   English   中英

迁移到Nginx之后,Wordpress永久链接

[英]Wordpress permalink after migrating to Nginx

我的永久链接是~~/%category%~~/%postname%/~~.html~~ 我从Apache迁移到Nginx。 然后我添加的配置文件

server{
location /mydirectory/ {
    try_files $uri $uri/ /mydirectory/$uri.html;
}

但是我的浏览器继续进入404页面。 我尝试删除缓存后找到了许多代码,但仍然没有成功。任何帮助将不胜感激,谢谢

我停用了所有插件,并能够将永久链接更改为

/%postname%/

这是我的my.site.com配置(我的网站在子目录Vie /中):

server {
listen 80;
server_name my.site.com;
location ~ /(vie|\|Vie|Vie)/(.*) {
return 301 https://my.site.com/Vie;
}
return 301 https://my.site.com/Vie$request_uri;
}

 server {
    listen 443 ssl;
server_name   my.site.com;
root /var/www/my.site.com/html;
index index.php index.html;

ssl_certificate /etc/letsencrypt/live/krouus.company/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/krouus.company/privkey.pem;

 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

 ssl_prefer_server_ciphers on;
 ssl_ciphers 'DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-CAMELLIA256-SHA:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-CAMELLIA128-SHA:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA256';

 ssl_session_cache shared:SSL:10m;
 ssl_session_timeout 10m;


 ssl_dhparam /etc/nginx/dhparam.pem;


add_header Strict-Transport-Security "max-age=31536000;";

location /Vie/ {
index index.php;
    try_files $uri $uri/ /Vie/index.php?$args;
}


location / {
    try_files $uri $uri/ /Vie/index.php;
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_intercept_errors on;
        fastcgi_ignore_client_abort off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffers 4 256k;
        fastcgi_buffer_size 128k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
}
    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
            include fastcgi_params;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME       
    $document_root$fastcgi_script_name;
}


    location ~* commun {
        deny all;
} 


 location = /favicon.ico {
    log_not_found off;
    access_log off;
}

location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
}
    location ~ /\.ht {
    deny  all;
}
location ~ (^|/)\. {
    return 403;
}
        location ~* \.(?:css|gif|htc|ico|js|jpe?g|png|swf)$ {
        expires max;
        log_not_found off;
        ## No need to bleed constant updates. Send the all shebang in one
        ## fell swoop.
        tcp_nodelay off;
        ## Set the OS file cache.
        open_file_cache max=1000 inactive=120s;
        open_file_cache_valid 45s;
        open_file_cache_min_uses 2;
        open_file_cache_errors off;
    }
location ~* \.ini$ {
    deny all;
    return 404;
}
    error_page 404 /404.html;
       location /404.html {
       internal;
     }

    location ~* /(?:uploads|files)/.*\.(html|htm|shtml|php|js|swf|py|jsp|asp|sh|cgi)$ {
    deny all;
    }
    if ($request_method !~ ^(GET|POST|HEAD)$ ) {
  return 444;
   }

  location ~* wp-includes/theme-compat/ {
    deny all;
   }

 location ~* wp-includes/js/tinymce/langs/.*.php {
    deny all;
 }

location /wp-includes/ {
internal;
}
 location ~* .(pl|cgi|py|sh|lua|asp)$ {
     return 444;
  }
 location ~* /(wp-config.php|readme.html|license.txt|nginx.conf) {
  deny all;
  }


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

 location /xmlrpc.php {
 deny all;
 }
}

试试这个吧。 由于我也面临着同样的问题,因此也希望它为您工作。

location /mydirectory{
    try_files $uri $uri/ /mydirectory/index.php;
}

好吧,事实上我解决了我的问题。 我仔细阅读了我的姿势,将其删除

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

现在,我的Wordpress可以工作了。

Cheerio!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM