Edit or Remove Plugin .htaccess Using The Admin Panel

You can delete files per plugin if the server’s PHP user has write permissions. The trick is to delete it immediately on activation. Here is a basic sample code:

<?php # -*- coding: utf-8 -*-
/**
 * Plugin Name: Delete .htaccess
 * Description: Deletes the .htaccess file on activation, deactivates itself then.
 * Plugin URI:  http://wordpress.stackexchange.com/q/58183/73
 *
 * Delete .htaccess, Copyright (C) 2012 Thomas Scholz
 */

register_activation_hook( __FILE__, 'wpse_58183_delete_htaccess' );
add_action( 'admin_notices', 'wpse_58183_admin_notice' );

function wpse_58183_delete_htaccess()
{
    $root = trailingslashit( $_SERVER['DOCUMENT_ROOT'] );
    unlink( $root . '.htaccess' );
}

function wpse_58183_admin_notice()
{
    echo '<div class="updated"><p><code>.htaccess</code> deleted.<br>Plugin deactivated.</p></div>';
    deactivate_plugins( basename( __FILE__ ) );
}

Download as ZIP file or see the code on GitHub.

But move the site to another server! As long as you cannot control the files per SSH or FTP chances are the site will be hacked again.

Leave a Comment