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

  • La Naranja Metálica #104 (9×12) 2 de octubre de 2025 Belisario
  • Terror en Blanco: Monstruos lacustres, con Javier Resines 2 de octubre de 2025 Javier Resines
  • Barren Path – Grieving(2025) 30 de septiembre de 2025 Nicholas Mkhl
  • Beats and yelling: Castrator 30 de septiembre de 2025 Hate Meditations
  • Reseñas breves (septiembre de 2025) 29 de septiembre de 2025 Belisario
  • Anica, la hija del orangután en la revista DeMisterios 27 de septiembre de 2025 Javier Resines
  • Beats and yelling shorts, 27th September 25 27 de septiembre de 2025 Hate Meditations
  • CAMINANDO ENTRE MONSTRUOS 02 (Bestiario Sonoro): Basandere, la señora de los bosques 25 de septiembre de 2025 Javier Resines
  • CAMINANDO ENTRE MONSTRUOS 01 (BESTIARIO SONORO): Anica, la hija del orangután 22 de septiembre de 2025 Javier Resines

Archivo

cuaderno de campo 2011-2025