Dokuwiki 的 Nginx 配置


server {
    listen       80;
    server_name  fanzhi.org www.fanzhi.org;

    charset utf-8;
    root   /srv/wiki;

    access_log  /var/log/nginx/fanzhi.org.access.log  main;

    if ($host != 'fanzhi.org') {
        rewrite ^/(.*)$ http://fanzhi.org/$1 permanent;
    }

    location / {
        index  doku.php;
        try_files $uri $uri/ @dokuwiki;
    }

    location @dokuwiki {
        rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;
        rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;
        rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;
        rewrite ^/(.*) /doku.php?id=$1 last;
    }

    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    location ~ ^/(data|conf|bin|inc)/ {
        deny  all;
    }

    location ~ ^/\.ht {
        deny  all;
    }
}