Je veux servir wordpress 3 multisite avec nginx, et voici ma conf nginx
server {
listen 80;
server_name lc.wp.com;
index index.html;
access_log /usr/local/var/log/nginx/lc.wp.access.log;
error_log /usr/local/var/log/nginx/lc.wp.error.log debug;
location / {
root /usr/local/www/playground/php/wordpress/;
autoindex on;
index index.html index.htm index.php;
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^.+?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /usr/local/www/playground/php/wordpress/;
rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$/wp-includes/ms-files.php?file=$1 last;
expires 30d;
break;
}
location ~ \.php {
root /usr/local/www/playground/php/wordpress/;
include /usr/local/etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
Je crée un sous-site "sub1", puis il se passe quelque chose d'étonnant :
Si je visite l'url ci-dessous, cela fonctionne normalement.
lc.wp.com/sub1/
lc.wp.com/sub1/hello/2011/06/16
si je visite
lc.wp.com/sub1/wp-admin/post-new.php?post_type=post
le serveur me dit 404 non trouvé
curl -I http://lc.wp.com/sub1/wp-admin/post-new.php\?post_type\=post
HTTP/1.1 404 Not Found
Server: nginx/1.0.2
Date: Thu, 16 Jun 2011 10:25:11 GMT
Content-Type: text/html
Connection: keep-alive
X-Powered-By: PHP/5.3.5
si je désactive l'analyse php (partie commentaire php), et que je configure
rewrite ^.+?(/wp-.*) $1 redirect;
Le serveur 302 s'est déplacé normalement, et m'a dit de sauvegarder le fichier post-new.php.
un peu fou maintenant. T_T