How to add custom rewrite rule for all web sites

#1
Hello, I want to add a rule that will be valid on existing and future websites without using a WordPress plugin. The purpose of this rule is to block requests to the xmlrpc.php file.
Apache config:
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteRule ^/xmlrpc\.php$ - [F,L]
</IfModule>
I saved this code in /etc/apache2/mods-available/disable_xmlrpc.conf and then

sudo service lsws restart
sudo service apache2 restart

I entered the commands but it didn't work. where is my problem?
 

abk

Administrator
Staff member
#2
For such case, where you want to block access to a specific file, instead of rewrite I would suggest a simple:
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
 

serpent_driver

Well-Known Member
#4
@lscpd
Place the code from @abk at the end of httpd.conf or use any include file of httpd.conf.

**********************************************************************************************************************************************************************************

Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.
support-partner-label.png
 
#5
@lscpd
Place the code from @abk at the end of httpd.conf or use any include file of httpd.conf.

**********************************************************************************************************************************************************************************

Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.
I can't find httpd.conf file or something like that
Apache config:
find / -name httpd.conf
possible with apache2.conf file?

/usr/local/lsws/add-ons/frontpage/conf/httpd.conf
/usr/lib/tmpfiles.d/httpd.conf
/usr/src/lsws/lsws-6.1.2/add-ons/frontpage/conf/httpd.conf
/etc/httpd/conf/httpd.conf
/usr/local/lsws/add-ons/frontpage/conf/httpd.conf

which one is it?
 

serpent_driver

Well-Known Member
#6
Don't edit httpd.conf and use any include config file instead because httpd.conf is overwritten by an update. httpd.conf and include files are located in /etc directory.

**********************************************************************************************************************************************************************************

Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.
support-partner-label.png
 
Last edited:
#7
Don't edit httpd.conf and use any include config file instead because httpd.conf is overwritten by an update. httpd.conf and include files are located in /etc directory.
So,
Apache config:
<Files xmlrpc.php>
order deny,allow
deny from all
</Files>
Will it be enough to create a /etc/my_custom.conf file and add it to it?
 

serpent_driver

Well-Known Member
#8
Will it be enough to create a /etc/my_custom.conf file and add it to it?
No, use the current config files.

**********************************************************************************************************************************************************************************
Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.

support-partner-label.png
 
Last edited:

serpent_driver

Well-Known Member
#10
control panel doesn't matter. In /etc directory or in /include subdirectory of /etc there are already config files that are inlcuded in httpd.conf.

btw. Do you use LSWS or OLS?

**********************************************************************************************************************************************************************************
Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.

support-partner-label.png
 
Last edited:

serpent_driver

Well-Known Member
#12
Ask Plesk support how to add custom configuration to httpd.conf. Maybe Plesk uses different handling.

**********************************************************************************************************************************************************************************
Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.

support-partner-label.png
 

serpent_driver

Well-Known Member
#14
Thank you for providing us with this information! Thumbs up

**********************************************************************************************************************************************************************************
Join https://www.cachecrawler.com - Lightning fast Cache Warmup Crawler for Wordpress, OpenCart, PrestaShop, W3 Total Cache, WP Rocket, Shopware and Magento.

support-partner-label.png
 
Top