Nginx, Wordpress and URL rewriting problems

2019-08-31 05:09发布

Trying to get Nginx and Wordpress to play nicely but it seems that they don't understand each other quite yet, especially in terms of pretty urls and rewriting.

I have the following snippet in my config file for nginx at the bottom (got it from Nginx's wiki page on WP), and I keep getting this error message in my error log, which makes me think it's not even trying to rewrite the location.

2011/04/11 09:02:29 [error] 1208#1256: *284 "c:/local/path/2011/04/10/hello-world/index.html" is not found (3: The system cannot find the path specified), client: 127.0.0.1, server: localhost, request: "GET /2011/04/10/hello-world/ HTTP/1.1", host: "dev.local:83"

If anyone can help give me direction or pointers or links or suggestions, that would be amazing because I'm seriously stuck. Thanks!

NGINX

worker_processes  1;
pid        logs/nginx.pid;

events {
    worker_connections  64;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    #gzip
    gzip on;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_proxied any;
    gzip_min_length  1100;
    gzip_buffers 16 8k;
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;

    # Some version of IE 6 don't handle compression well on some mime-types, so just disable for them
    gzip_disable "MSIE [1-6].(?!.*SV1)";
    # Set a vary header so downstream proxies don't send cached gzipped content to IE6
    gzip_vary on;


    server {
        listen       83;
        server_name  localhost  dev.local;
        root   c:/local/path;
        index  index.php;

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

        #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:521;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_intercept_errors on;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

}

1条回答
再贱就再见
2楼-- · 2019-08-31 05:21

Absolute paths like the one you specified gets translated into a /cygdrive/c/-path even if you don't have cygwin installed. For Windows I suggest you use relative paths if possible. Relative to the nginx directory.

查看更多
登录 后发表回答