Help with .htaccess file being overwritten
-
I am hosting WordPress on my home server and while it works great, I have enabled the apache status page so It can be accessed by the Apache HTTP Server Metrics Telegraf plugin and visualize it with Grafana.
The issue is whenever something changes my .htaccess file, my apache status page stops working. I believe it’s due to the location of the code which is inserted between the
BEGIN WordPress
andEND WordPress
which it’s clearly labeled that it will be overwritten. I have tried adding the code elsewhere in the file but then the apache status page becomes inaccessible.Here’s the .htaccess file in question (the line that controls apache status page is
RewriteCond %{REQUEST_URI} !=/server-status:
### Custom - Hardening WordPress ### <files wp-config.php> order allow,deny deny from all </files> ### Custom - Hardening WordPress ### # Disable directory listing. ### Custom - Hardening WordPress ### #Header set Strict-Transport-Security "max-age=31536000" env=HTTPS ### Custom - Hardening WordPress ### # Disable hotlink protection while allowing the sites below RewriteEngine on RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mywebsite.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?google.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?facebook.com [NC] RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?twitter.com [NC] RewriteRule \.(jpg|jpeg|png|gif)$ - [F] # BEGIN WordPress # The directives (lines) between "BEGIN WordPress" and "END WordPress" are # dynamically generated, and should only be modified via WordPress filters. # Any changes to the directives between these markers will be overwritten. <IfModule mod_rewrite.c> RewriteEngine On RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/server-status RewriteRule . /index.php [L] </IfModule> # END WordPress
Any ideas how to make this work?
- The topic ‘Help with .htaccess file being overwritten’ is closed to new replies.