Ajax response call, 404 Not Found

.htaccessajaxcodeigniterhttp-status-code-404Wordpress

i tried to use wordpress and codeigniter for a intelligent join between the best CMS and the best PHP Framework. Actually i intended to use codeigniter for database managemnent and wordpress for display. But i wanted to use codeigniter inside wordpress. So, i have a file tree like that:

www
- codigniter-core folder
  - .htaccess
- wordpress-core folder
- .htaccess
- index.php

How can i make the wordpress .htaccess to cover also the codeigniter ant not trowing 404 error in jquery ajax call. My current wordpress .htaccess file it's:

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^/codeigniter-core/
RewriteRule ^(.*)$ /index.php/$1 [L]

I also tried to ask this to WordPress Forums and Codeigniter Forums, but no answer. I think it's hell of a rewrite condition or rule, but i don't know …

Best Answer

I had this problem when creating a controller file that I would call via the jQuery ajax method. This controller file included wp-blog-header.php.

When you include the wp-blog-header.php in a file outside of WP framework WordPress does a check on the current file, and if it is not in its database it returns a 404. The work around is to add a 200 status header after the wp-blog-header.php.

header("HTTP/1.1 200 OK");

Now (jQuery) ajax to the file returns properly without a 404.