I came across this topic : How can I rename the WordPress AJAX URL? on trying to rename the url for the admin ajax.php file. I tried the code suggested by Krzysiek Dróżdż which is this

// This will change the url for admin-ajax.php to /ajax/
function modify_adminy_url_for_ajax( $url, $path, $blog_id ) {
    if ( 'admin-ajax.php' == $path ) {
        $url = site_url('/ajax/');

    return $url;
add_filter( 'admin_url', 'modify_adminy_url_for_ajax', 10, 3 );


RewriteRule ^/?ajax/?$ /wp-admin/admin-ajax.php?&%{QUERY_STRING} [L,QSA]

But I am getting post 404's under the renamed /ajax/ url and was wondering what I could be doing wrong and if this code would still work on newer versions ?


1 Answer 1


you can try this: https://github.com/devgeniem/wp-no-admin-ajax

"A WordPress plugin that changes the WP AJAX routine and rewrites the ajax requests to custom url rather than admin-ajax.php back-end."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.