WordPress 3.0 & nginx - permalink, 404 problem

前端 未结 8 2069
清歌不尽
清歌不尽 2021-02-08 16:26

I\'ve installed nginx, FastCGI and PHP on my server. WordPress 3.0 installed after a bit of a monster battle, but it\'s installed and working well.

However, when I chang

相关标签:
8条回答
  • 2021-02-08 16:51

    I did the following..

    in the folder /home/userrunningnginx/nginx/domain.com

    I have:

    default.conf (file)

    include /home/neukbaarofnietps/nginx/neukbaarofniet.com/drop;
    

    drop (file)

    # Rather than just denying .ht* in the config, why not deny
    # access to all .invisible files
    location ~ /\. { deny  all; access_log off; log_not_found off; }
    

    nginx.conf (file)

    location / {
    index index.php index.html index.htm;
    try_files $uri $uri/ /index.php?$args;
    

    }

    WORDPRESS-NGINX.CONF (file)

     #######################
    # WP Super Cache
    
    # if the requested file exists, return it immediately
    if (-f $request_filename) {
      break;
    }
    
    set $supercache_file '';
    set $supercache_uri $request_uri;
    
    if ($request_method = POST) {
      set $supercache_uri '';
    }
    
    # Using pretty permalinks, so bypass the cache for any query string
    if ($query_string) {
    set $supercache_uri '';
    }
    
    if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
    set $supercache_uri '';
    }
    
    # if we haven't bypassed the cache, specify our supercache file
    if ($supercache_uri ~ ^(.+)$) {
    set $supercache_file /wp-content/cache/supercache/$http_host$1/index.html;
    }
    
    # only rewrite to the supercache file if it actually exists
    if (-f $document_root$supercache_file) {
    rewrite ^(.*)$ $supercache_file break;
    }
    
    # all other requests go to Wordpress
    if (!-e $request_filename) {
    rewrite ^.*$ /index.php last;
    }
    
    0 讨论(0)
  • 2021-02-08 16:57

    Adding this block to your nginx.conf should solve the issue:

         if (!-e $request_filename) {
                rewrite ^/wordpress_dir/(.+)$ /wordpress_dir/index.php?q=$1 last;
         }
    

    Hope this helps.

    Good luck.

    0 讨论(0)
提交回复
热议问题