Saltar al contenido

cuaderno de campo

anotaciones

Menú
  • casa
    • dinou del carrer nou
  • cocina
    • pan
    • repostería
    • verdura
  • huerto
    • instrucciones sobre el huerto
    • plano del número 29
    • huerto del año 2025
  • humanidades
    • fonoteca
    • galería
  • juego
    • colección de roms
    • steamos en steam deck
    • lista de juego
    • dosbox
  • linux
    • bash
    • sistema operativo
    • ssh
  • web
    • apache
    • css
    • html5
    • javascript
    • mysql
    • php
Menú

prevención del hotlinking de imágenes

Publicada el 1 de diciembre de 201726 de febrero de 2021 por ernesto
<IfModule mod_rewrite.c>
     RewriteEngine on
     RewriteCond %{HTTP_REFERER} !^$
     RewriteCond %{HTTP_REFERER} !^http(s)?://(www.)?poderna.com/.*$ [NC]
     RewriteRule .(jpg|png)$ http://poderna.com/archivo/imagen/editor.png [NC,R,L]
</IfModule>

tras poner en marcha el motor de rescritura con rewriteengine (mod_rewrite), se establecen dos condiciones mediante rewritecond:  si no hay http referer (!^$) o si éste no se corresponde con el dominio poderna.com, se aplica la siguiente regla de rescritura (rewriterule): al patrón «.(jpg|png)$» (esto es, a la solicitud de un archivo cuya extensión sea jpg o png) se lo sustituye por http://poderna.com/archivo/imagen/editor.png con las siguientes banderas como condición:

NC
Use of the [NC] flag causes the RewriteRule to be matched in a case-insensitive manner.

R
Use of the [R] flag causes a HTTP redirect to be issued to the browser [...] Any valid HTTP response status code may be specified, using the syntax [R=305], with a 302 status code being used by default if none is specified.

L
The [L] flag causes mod_rewrite to stop processing the rule set.

también es posible devolver un error en lugar de otra imagen:

RewriteRule .(jpg|png)$ - [F,L]

donde

F
Using the [F] flag causes the server to return a 403 Forbidden status code to the client.

fuente: dreamhost.com.

Etiquetado como rewritecond, rewriteengine, rewriterule
  • desactivación de las etags

    FileETag None <IfModule mod_headers.c> Header unset ETag </IfModule> esta es la manera de excluir el…

  • acceso a los directorios

    Options All -Indexes la directiva options «configures what features are available in a particular directory».…

  • cabeceras de codificación e idioma

    AddDefaultCharset UTF-8 DefaultLanguage es la directiva adddefaultcharset (core) permite los «media type's charset parameters» definidos…

RSS rutas fuera

  • CAMINANDO ENTRE MONSTRUOS 04 (Bestiario Sonoro): Drac de Na Coca 23 de octubre de 2025 Javier Resines
  • Karbach Brewery Rodeo Clown Double IPA (2025) 22 de octubre de 2025 Brett Stevens
  • Beats and yelling: Cultic 22 de octubre de 2025 Hate Meditations
  • Beats and yelling shorts, 20th October 25 20 de octubre de 2025 Hate Meditations
  • Karbach Brewery Hopadillo Imperial IPA (2025) 20 de octubre de 2025 Brett Stevens
  • Eureka Heights Final Boss Imperial IPA (2025) 20 de octubre de 2025 Brett Stevens
  • Tertulia con Juan Gomez, Pablo Vergel y Álvaro Martín: Spring-heeled Jack 19 de octubre de 2025 Javier Resines
  • Beats and yelling: Heruvim 17 de octubre de 2025 Hate Meditations
  • Please read the following scenario carefully 15 de octubre de 2025 Hate Meditations

Archivo

cuaderno de campo 2011-2025