Redirect to Apache default 404 page with mod_rewrite?

Posted by Pekka on Stack Overflow See other posts from Stack Overflow or by Pekka
Published on 2010-03-15T12:42:22Z Indexed on 2010/03/15 13:09 UTC
Read the original article Hit count: 218

Filed under:
|
|

Is there a way to actively serve Apache's default 404 page for a number of URLs using mod_rewrite? Not a custom error document, but a rule like

RewriteCond %{REQUEST_URI} ^/dirname/pagename
RewriteRule -- serve 404 page -----

I guess I could build a PHP page that sends the 404 header and have mod_rewrite redirect all the URLs there but I would prefer a solution that is based on mod_rewrite only.

I just had the idea of redirecting to a non-existent address:

RewriteCond %{REQUEST_URI} ^/dirname/pagename
RewriteRule .* /sflkadsölfkasdfölkasdflökasdf

but that would give the user the message "/sflkadsölfkasdfölkasdflökasdf does not exist" on the error page, which looks a bit unprofessional.

© Stack Overflow or respective owner

Related posts about apache

Related posts about mod-rewrite