Apache Webserver

From wiki.linuxonlinehelp.eu
Jump to navigation Jump to search

Redirects for Browser with .htaccess

Redirect Browser by Language to other Websites

Create a .htaccess at the Webspace and enter:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:Accept-Language} ^de [NC]
RewriteRule ^$ /linux-support-deutsch [L,R=301]
RewriteRule ^$ /linux-support-english [L,R=301]
</IfModule>

This will redir German and International Users to two different Sites.

Block Access to Subfolders wp-includes of Wordpress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>

Analyses and Diagnostics

Apache Log analyse on Console

create a bash script called apache-analyse.sh enter:

#!/bin/bash
cat /var/log/apache2/access.log | awk '{ print $1 }' | sort | uniq -c
exit 0

System Echos like this:

1573  www.domain2.de
3568  www.domain3.de
..

Analyse Spam Bots and block them

get IP Adresses from Spambots (here xovibot) to update the Firewalls do:

sudo cat /var/log/apache2/access.log|grep xovibot.net| awk '{ print $2 }' | sort | uniq -c | sort -n > x.log

System Echos:

     46 212.224.119.143
     52 185.53.44.101
     54 212.224.119.140
     59 185.53.44.104
     62 212.224.119.142
     71 185.53.44.102
     75 185.53.44.103
     80 185.53.44.67
     80 212.224.119.141
     83 185.53.44.68
     87 185.53.44.43
     ...

manual update to ufw firewall (can be done automatic too, but can take you offline for search engines if the do 404) do:

$sudo ufw insert 1 deny from 185.53.44.0/24 to any       # insert rule
$sudo service ufw force-reload                           # force update firewall
$sudo ufw status numbered                                # test status