我使用的是Nginx和一个自定义的add\\u rewrite\\u规则,如下所示:
function add_pony() {
//this should allow me to POST to domain.com/pony
add_rewrite_rule(\'^pony$\', \'index.php?pony=true\', \'top\');
}
add_action( \'init\', \'add_pony\');
function parse_pony( $params ) {
if(isset($params->query_vars[\'pony\'])){
//kick off endpoint specific code
}
return $params;
}
add_action( \'parse_request\', \'parse_pony\' );
我的WP的nginx配置如下所示:
server {
listen 80;
root /var/www/domain.net;
index index.php;
server_name domain.net;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
location ~ \\.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_intercept_errors on;
include fastcgi_params;
}
}
当我发布或获取新URL时,我会得到一个404。WordPress的其余部分工作正常,但当我将permalink设置更改为post name以外的内容时,WordPress就会停止正常工作。
我被难住了。