Welcome! Log In Create A New Profile

Advanced

Ajax not working on Nginx / Wordpress

cs
August 06, 2010 04:58AM
ahoy,

i'm running wordpress 3x on nginx and all my ajax calls are broken. the exactly same wordpress runs fine on Apache.

i've fixed somehow an ajax call to work with nginx by removing 'index.php' from all jquery.post() calls, but i couldn't fix the other calls in the same way.

basically the changes were:
for nginx the line:
jQuery.post( 'index.php?ajax=true', form_values, function(returned_data) {

was replaced with:
jQuery.post( '?ajax=true', form_values, function(returned_data) {


i suspect the problem lies in the nginx config file with rewrite rules. There you are with my configuration

# this sends all non-existing file or directory requests to index.php
#if (!-e $request_filename) {
# rewrite ^(.+)$ /index.php?q=$1 last;
#}
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /xxx/public$fastcgi_script_name;
include fastcgi_params;
}
}
Subject Author Posted

Ajax not working on Nginx / Wordpress

cs August 06, 2010 04:58AM

Re: Ajax not working on Nginx / Wordpress

jozwikjp December 01, 2010 08:49AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 187
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready