I was reading this answer, and tried to used its guide to hide login page. It suggest to edit .htaccess
file of my website to something like this:
RewriteEngine On
RewriteBase /
##### ABOVE THIS POINT IS ALREADY INSERTED BY WORD PRESS
##### Michi’s code is BELOW #####
RewriteCond %{REQUEST_URI} wp-admin/
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule .*\.php [F,L]
RewriteCond %{QUERY_STRING} !YOURSECRETWORDHERE
RewriteRule ^ADMINFOLDER/(.*) wp-admin/$1?%{QUERY_STRING}&YOURSECRETWORDHERE [L]
##### Michi’s code is ABOVE #####
##### BELOW THIS POINT IS ALREADY INSERTED BY WORD PRESS
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
My .htaccess
file starts with these lines:
# 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]
</IfModule>
# END WordPress
I want to know if I add anything between # BEGIN WordPress
and # END WordPress
is it possible that it will be overwritten by wordpress or not? This is usual about automated scripts but since it is not mentioned any warnings, I want to know may be it is safe to add some rules inside this block.
4 Answers
WordPress uses those markers to put its rules between. I never have and never would put custom rules in there.
Check out insert_with_markers()
and save_mod_rewrite_rules()
in
wp-admin/includes/misc.php
Most notably this comment block which answers your question:
/**
* Inserts an array of strings into a file (.htaccess ), placing it between
* BEGIN and END markers.
*
* Replaces existing marked info. Retains surrounding
* data. Creates file if none exists.
*/