0

We are getting rid of some spammy inbound links to our site. This means we want to have these links resolve as '404 not found'. I am having problems sorting out the basic .htaccess modification needed to do this.

I want any links starting with 'www.example.com/cgi-bin/dir' to give a 404 code, thus I added this to my .htaccess in the www directory:

RewriteRule ^cgi-bin/dir.*$ - [L,R=404]

I got to this line of code by combining the answers to this and this question. It works fine on 'www.example.com/cgi-bin/dir' itself, but does not work for any link lower down the directory. Non-working links include links like 'http://www.example.com/cgi-bin/dir/search.cgi'. There is no .htaccess file in the cgi-bin folder, or the relevant subfolders.

Any ideas?

Coert Grobbelaar
  • 627
  • 4
  • 14

1 Answers1

1

I ended up creating an .htaccess file in the cgi-bin/dir directory. It contains these lines:

RewriteEngine On
RewriteRule ^(.*)$ - [R=404,L]

I'm guessing the problem was that the .htaccess in the www directory was not being read, because we were entering the cgi-bin directory, which is on the same level as the www directory, not inside it.

Coert Grobbelaar
  • 627
  • 4
  • 14