1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to block all external elements loading using .htaccess?

Discussion in 'Apache' started by postcd, Mar 21, 2022.

  1. #1
    Hello,

    i want to block loading of all elements loaded from external sites. For example embeding images that are hosted on different domains.

    My failed attempt is:
    # Disable external content
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http(s)?://(subdomain.)?mydomain.com [NC]
    RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?mydomain.com [NC]
    RewriteRule \.(jpg|jpeg|png|gif|bmp|webp)$ - [F]
    Code (markup):
    In last line i have mentioned some extensions though i would prefer blocking everything, except for example filename externalcaptcha.js and otherexternal.file

    Thank You
     
    postcd, Mar 21, 2022 IP