Asegurando WordPress con .htaccess
He hablado muchas veces del fichero .htaccess, un archivo que, aunque no pertenece a la instalación de WordPress, es necesario para que funcionen muchas cosas que seguro necesitaremos, desde los enlaces permanentes hasta la protección de nuestras carpetas.
Pero como andaba todo algo disperso he pensado que, en estos tiempos que corren, no está de mas un recordatorio y, por supuesto, un resumen.
Pero antes vamos a ver lo que ya había por si te has perdido algo, luego escribimos las líneas para que tu .htaccess asegure tu WordPress.
¿Hacemos una recopilación? …
- Qué es el hotlinking y como protegerte (también con .htaccess claro)
- Protege tu .htaccess
- Restringir acceso al Escritorio por IP
- Cómo banear por IP o dominio desde .htaccess
- Redirección por .htaccess mientras actualizas
- Evitar spam blogs (splogs) en BuddyPress y WPMU mediante .htaccess
- Evita comentarios spam desde .htaccess
- Modifica el fichero .htaccess desde el Escritorio
- Como mostrar los mensajes de error de WordPress
- Regala un error 403 a los curiosos
- Proteger la carpeta wp-admin
- Y hasta publiqué un .htaccess perfecto para WordPress
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | # Asegurando WordPress # Desactivar la firma de servidor ServerSignature Off # Desactivar el listado de carpetas y archivos Options All -Indexes # Protegiendo el mismo fichero htaccess <files .htaccess> order allow,deny deny from all </files> # Protegiendo htaccess de manera extrema <files ~ "^.*\.([Hh][Tt][Aa])"> order allow,deny deny from all satisfy all </files> # Protegiendo wp-admin por IP AuthUserFile /dev/null AuthGroupFile /dev/null AuthName “Access Control” AuthType Basic order deny,allow deny from all # IP cuando estoy en casa allow from xx.xxx.xxx.xx # IP cuando estoy en el trabajo allow from xx.xxx.xxx.xxx allow from xxx.xxx.xxx.200 # IP de otro usuario con permisos allow from xxx.xxx.x.xx # Protegiendo el fichero wpconfig.php <files wp-config.php> order allow,deny deny from all </files> # Protegiéndonos de los commentarios spam <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .wp-comments-post\.php* RewriteCond %{HTTP_REFERER} !.*tublog.com* [OR] RewriteCond %{HTTP_USER_AGENT} ^$ RewriteRule (.*) ^http://%{REMOTE_ADDR}/$ [R=301,L] </IfModule> # Desactivando el hotlinking con un mensaje de aviso <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://www.xyz.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://www.xyz.com$ [NC] RewriteCond %{HTTP_REFERER} !^http://xyz.com/.*$ [NC] RewriteCond %{HTTP_REFERER} !^http://xyz.com$ [NC] RewriteCond %{HTTP_REFERER} !google. [NC] RewriteCond %{HTTP_REFERER} !msn. [NC] RewriteCond %{HTTP_REFERER} !live. [NC] RewriteCond %{HTTP_REFERER} !yahoo. [NC] RewriteCond %{HTTP_REFERER} !gravatar. [NC] RewriteCond %{HTTP_REFERER} !search?q=cache [NC] RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ - [F,NC] </IfModule> # Baneo por IP <Limit GET POST> order allow,deny deny from xx.xx.xxx.xxx /aquí pones la IP a banear allow from all </Limit> # Baneo por dominio RewriteEngine On Options +FollowSymlinks RewriteCond %{HTTP_REFERER} dominio_a_banear\.com [NC] RewriteRule .* - [F] # Evitar splogs RewriteEngine On RewriteCond %{REQUEST_METHOD} POST RewriteCond %{REQUEST_URI} .wp-signup.php* RewriteCond %{HTTP_REFERER} !.*miwordpressmu.com.* [OR] RewriteCond %{HTTP_USER_AGENT} ^$ RewriteRule (.*) http://disney.com/ [R=301,L] |
Unos detalles …
- La «serversignature» es un texto en los mensajes de error que indica la versión de Apache que usamos e incluso el email del administrador
- ¡Ojo!, no pegues directamente eso en tu .htaccess, que hay muchas líneas de ejemplo
Ea, a ir seguro por esas webs, que hay mucho Apache suelto 😉
¿Te gustó este artículo? ¡No sabes lo que te estás perdiendo en YouTube!