浏览 2617 次 / [ 天下网闻 ] Wordpress固定链接去掉url中index.php后404的解决方法[linux]
  • 发布时间 2017-11-07 12:56
  • WP新站,只安装了远程附件和备份两个插件。添加了筛选功能后,固定链接里去掉index.php之后筛选页面出现404;
    解决方法:

    找到配置文件:
    1. server
    2. {
    3.     listen 80;
    4.     server_name logo.doooor.com;
    5.     index index.php index.html index.htm default.php default.htm default.html;
    6. root /www/wwwroot/logo.doooor.com;
    7.     #error_page 404/404.html;
    8.     error_page 404 /404.html;
    9.     error_page 502 /502.html;
    10.    
    11.     include enable-php-70.conf;
    12.     include /www/server/panel/vhost/rewrite/logo.doooor.com.conf;
    13.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    14.     {
    15.         expires      30d;
    16.         access_log off;
    17.     }
    18.     location ~ .*\.(js|css)?$
    19.     {
    20.         expires      12h;
    21.         access_log off;
    22.     }
    23.     access_log  /www/wwwlogs/logo.doooor.com.log;
    24. }
    复制代码
    添加一段:
    1. try_files $uri $uri/ /index.php?$args;
    复制代码
    最终结果为:
    1. server
    2. {
    3.     listen 80;
    4.     server_name logo.doooor.com;
    5.     index index.php index.html index.htm default.php default.htm default.html;
    6.     try_files $uri $uri/ /index.php?$args;
    7.     root /www/wwwroot/logo.doooor.com;
    8.     #error_page 404/404.html;
    9.     error_page 404 /404.html;
    10.     error_page 502 /502.html;
    11.    
    12.     include enable-php-70.conf;
    13.     include /www/server/panel/vhost/rewrite/logo.doooor.com.conf;
    14.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    15.     {
    16.         expires      30d;
    17.         access_log off;
    18.     }
    19.     location ~ .*\.(js|css)?$
    20.     {
    21.         expires      12h;
    22.         access_log off;
    23.     }
    24.     access_log  /www/wwwlogs/logo.doooor.com.log;
    25. }
    复制代码
    保存,重启nginx。