Reputation: 116
I need to block visits to specific URLs within my site. But I am unsure how to, and is terrible at understanding the intricacies of htaccess. ^^
I need to block visits that are accessing these type of URLs, for eg.
My current htaccess code
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !\.(png|gif|ico|swf|jpe?g|js|css)$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php?sef_rewrite=1 [L,QSA]
</IfModule>
<Files 403.shtml>
order allow,deny
allow from all
</Files>
deny from xx.xx.xx.xx
deny from xx.xx.xx.xx
What should I enter into htaccess to block these visits? And in which order? Before my current code or after?
Upvotes: 0
Views: 5320
Reputation: 5437
You may or may not wish to use mod_alias
if you've got it available; the syntax is slightly more readable but it will only match paths (i.e. not query-strings):
<IfModule mod_alias.c>
Redirect 403 /katherine-blouse-on-fire
Redirect 403 /antique-for-preservation
</IfModule>
Upvotes: 0
Reputation: 12727
Add the below after your RewriteBase /
before RewriteCond %{REQUEST_FILENAME} !\.(png|...
. It will return a 403 Forbidden status code
to the client.
RewritCond %{REQUEST_URI} (?:(?:katherine-blouse-on-fire)|(?:antique-for-preservation)) [NC,OR]
RewritCond %{QUERY_STRING} type\=extended&name\=stackoverflow [NC]
RewriteRule ^ - [F]
Definition:
Upvotes: 1