apache rewrite htaccess preventing ajax

So I have added some rewrite rules to my htaccess and they are working well, but are preventing AJAX POST requests from passing data in the redirect (i think). I get 500 errors.

Here is my htaccess file:

RewriteEngine On

# remove trailing slash
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [NC,L]

# browser requests PHP
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^ ]+).php
RewriteRule ^/?(.*).php$ /$1 [L,R=301]

# check to see if the request is for a PHP file:
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^/?(.*)$ /$1.php [L]

RedirectMatch permanent ^([0-9]{4})_([0-9]{2}).php$ $1/$2

And a standard ajax call:

$.ajax({
    type: "POST",
    url: "get_recent_edits",
    data: {id: id content_type: contentType},
    dataType: "json",
    success: function (data) {
    },
    error: function (data) {

    }
});

It doesn’t seem to make any difference wether my AJAX url has the .php extension or not.

Sincere thanks for any help. It is greatly appreciated.


Source: apache

Leave a Reply