Ajax response call, 404 Not Found
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 curre开发者_如何转开发nt 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 ...
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.
This worked great... can't tell you how long I was looking for this answer. I suspected this had to do with a header error because firebug showed the response but the header had a 404. Thanks this saved me a lot of time.
BTW I used this to fix the Quick Search plugin by Giulio Ganci
Just open the "search.php" file in the plugin folder and add
header("HTTP/1.1 200 OK");
Right after the first line of code. When your done the first few lines of code in this file should look like this
<?php
require('../../../wp-blog-header.php');
header("HTTP/1.1 200 OK");
if (isset($_GET['s']) && trim($_GET['s']) != '') {
精彩评论