Forum Moderators: phranque

Message Too Old, No Replies

How to 404 an entire domain

         

JohnKelly

1:37 am on Nov 13, 2005 (gmt 0)

10+ Year Member



I have two domains that point to the same site. Currently domain2 is 301 redirected to domain1 using the .htaccess file.

Due to some old pages on domain2 still being listed in Google, I want to temporarily 404 *all* pages under domain2, without affecteting any under domain1.

I've tried the obvious (to me) codes, but they lead to errors.

Any ideas?

outrun

2:46 am on Nov 13, 2005 (gmt 0)

10+ Year Member



You could rename the folder that your files are in domain2 or use Auto prepend with htaccess with some thing like this in your htaccess


auto_prepend_file /path/to/404file.inc

and have something like this in that file


header("HTTP/1.0 404 Not Found");
exit();

JohnKelly

5:02 am on Nov 13, 2005 (gmt 0)

10+ Year Member



Thanks, but I couldn't get that to work... produced a 500 server error.

jd01

5:22 am on Nov 13, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will need to use a HOST condition:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain2.com
RewriteRule .? - [G]

Will give them a status of GONE (410)...

to use a true 404, you will have to redirect to a non-existant page, which will force a redirect, then a 404:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain2.com
RewriteRule .? http://www.domain2.com/some-not-real-page.html [R=301,L]

Hope this helps.

Justin

JohnKelly

2:06 am on Nov 14, 2005 (gmt 0)

10+ Year Member



Thanks jd01, I used the 410 Gone solution.

jdMorgan

2:37 am on Nov 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a note on the second technique:

You don't have to redirect to the non-existent page -- an internal rewrite will work just as well, and avoid confusing the 'bots:


RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain2\.com
RewriteRule .* /non-existent-page.html [L]

Jim