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 ?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.