Creating a 404 error for a specific page with special characters


We need to send a 404 return code error for a specific URL on our site. (required because a client complains the URL is still in google, despite the content not existing).

The issue is tricky because the URL contains special characters that Apache appears not to want to exist in our htaccess file:


Any ideas how I could correctly accomplish this?


%3C = < so WHY would Google use /application/archive/index.php/</</p-204021.html? That’s insane!

Okay, mod_rewrite WILL accommodate that with:

RewriteRule ^/?application/archive/index\\.php/[<]/[<]/p-204021\\.html$ - [R=404,F,L]

If mod_rewrite objects escape the <'s with \ for [^\<] and that’ll do the trick.

You just have to remember that Apache IS smart enough to know what the encoded character is but mod_rewrite’s NOT very accommodating to encoded characters so you MUST use the character within a character range definition.



Hi David,

I have no idea how Google got this URL in its index. :frowning:

Thanks for the suggestions. I knew some escaping was probably required, but everything I attempted was causing server errors.

So your suggestion stopped the server errors. But Apache appears to be ignoring the rewrite rule. The web server is still returning a 200 code. (which is what has been doing all day regardless of what I try)


Perhaps changing the passthrough (the -) to your 404 script’s page will make the difference?



Argh idiot I am! But it’s not redirecting it just throws a 404 not found message and:

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.