• Resolved tandelk

    (@tandelk)


    On every website of WordPress i use Wordfence as a first Plugin as soon as new WordPress is installed on the website i work on. I had added couple of codes in .htaccess file after the WAF Config addition by Wordfence. I added 2 things first of all Website redirect from HTTP to automatically HTTPS and second was to deny xmlrpc from everywhere.
    For couple of days i think all the websites have the code and again it goes away making it to default of WordPress Rewrite Condition and Wordfence WAF Config only left in my .htaccess file. Is it anything to do with Wordfence ?

    The solution is not going to be installing additional plugins to do the same things which can be achieved with simple 10-15 lines of code.

    • This topic was modified 5 years, 1 month ago by tandelk.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey @tandelk,

    Where are you placing the code? Can you share the contents of your htaccess with all of the rules in it?

    The custom code you’re adding needs to be in its own code block to avoid overwrites.

    Thanks,

    Gerroald

    Thread Starter tandelk

    (@tandelk)

    Currently i did was i added the Retwrite Condition in default WordPress section
    @wfgerald

    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    Options -Indexes
    
    RewriteCond %{HTTP_HOST} ^mywebsitehere\.com [NC]
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.mywebsitehere/$1 [R=301,L]
    
    </IfModule>
    # END WordPress
    # Block WordPress xmlrpc.php requests
    <Files xmlrpc.php>
    order deny,allow
    deny from all
    </Files>
    • This reply was modified 5 years, 1 month ago by tandelk.
    Thread Starter tandelk

    (@tandelk)

    So as per what you have told me about

    The custom code you’re adding needs to be in its own code block to avoid overwrites.

    I am currently making them changes outside default WordPress Section something like

    #BEGIN HTTPS Redirect
    <IfModule mod_rewrite.c>
    Options -Indexes
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^mywebsitehere\.com [NC]
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.mywebsitehere/$1 [R=301,L]
    </IfModule>
    # END HTTPS Redirect

    Using above as a seperate section after #END WordPress area. If it is correct just let me know .

    Hey @tandelk,

    This looks perfect. Anytime the htaccess is updated for any reason all of the blocks of code are rewritten. This will prevent WordPress from rewriting over your added code.

    Please do let us know if anything else comes up.

    Thanks,

    Gerroald

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘.htaccess getting modified to default by itself’ is closed to new replies.