2

I have read about how to do this using the following:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*website\.com [NC]
    RewriteRule .* - [F]
    </IfModule>

However, I can't figure out how to use it in combination with what is currently there now:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
1

block a domain

You presumably mean "block a referer".

You just need to put that bit of code before the existing directives. Otherwise, if you put it at the end (after the front controller) then it will never be processed.

You don't need the additional <IfModule> wrapper and certainly not the additional RewriteEngine directive (although it does no harm). For example:

RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*website\.com [NC]
RewriteRule .* - [F]

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

In fact, you probably don't need the <IfModule> wrapper at all - but if this is auto-generated by your CMS (eg. WordPress) then leave it.

But otherwise...

RewriteEngine On

# Block
RewriteCond %{HTTP_REFERER} ^https?://([^.]+\.)*website\.com [NC]
RewriteRule .* - [F]

# Front controller
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
  • 1
    Yes, referrer domain thank you, that works great...thanks so much! – cl1fe Aug 16 '17 at 18:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.