How to force a 404 or 410 for a url
Easy enough to do on an Apache server with the mod_rewrite module enabled, using the .htaccess file.
Add these directives (adjusted for your particular situation):
RewriteEngine on ## list uris which are supposed to return 404 are rewritten to a non-existent url which returns a 404 anyway - the server is supposed to respond with a 404** RewriteRule ^(.*)/path-to/url-of-bad-page-i-want-to-see-gone-forever\.html$ http://www.example.com/nonexistent-file-which-gives-404.php
## list uris which are supposed to return 410 RewriteRule ^(.*)/path-to/url-of-bad-page-i-want-to-see-gone-forever\.html$ - [G] ## custom error documents - note that you use only their uri - relative to the root (/) - NEVER use the fully qualified url withhttp://www.exampe.com/ part.
ErrorDocument 404 /error-404.php ErrorDocument 410 /error-410.php
**In cases when the server does not respond with a 404 naturally for a non-existent file, then make a php script called nonexistent-file-which-gives-404.php containing this code in it:
<?php header( "HTTP/1.1 404 Not Found" ); exit; ?>
Even though the file exists, it responds with a 404 – so as far as the server is concerned and any user agent checking the response, it does not exist.
RewriteEngine on
RewriteCond %{QUERY_STRING} (^|&)parm1= [NC]
RewriteCond %{QUERY_STRING} (^|&)parm2= [NC]
RewriteCond %{QUERY_STRING} (^|&)parm3= [NC]
RewriteRule (.*) /error-404.php? [R=404,L]
RewriteEngine on
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) /error-404.php? [L,R=404]
RewriteEngine on RewriteCond %{THE_REQUEST} !^.*\/wp-login\.php?(.*) RewriteCond %{THE_REQUEST} !^.*\/wp-admin\/(.*) RewriteCond %{QUERY_STRING} . [NC] RewriteCond %{QUERY_STRING} !^s= [NC] #### to allow for search page urls RewriteCond %{QUERY_STRING} !^ver= [NC] #### to allow for .js and .css files that have version numbers RewriteCond %{QUERY_STRING} !^rsd= [NC] #### to allow for some feed urls RewriteRule (.*) /my-404.php? [L,R=404] #### my-404.php is a dummy 404 page uri - it could be nearly anything