You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by peter pilsl <pi...@goldfisch.at> on 2006/03/16 13:06:16 UTC

[users@httpd] return 404 for specific url ?

I want to configure a virtual host to return 404 for a specific request

I tried mod_rewrite

RewriteRule ^/(forbidden_.*) - [R=404]

but this does not work. Also didnt find anything in mod_alias.

I would need to redirect to a nonexisting url, so the browser would 
receive a 301 first and then get the 404, which is not what I need !! 
The first answer need to be a 404.  I hope there is a solution inside 
apache, otherwise I would need to rewrite my application to return 404 
itself.

thnx,
p

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] return 404 for specific url ?

Posted by Robert Ionescu <ro...@googlemail.com>.
peter pilsl wrote:
> 
> I want to configure a virtual host to return 404 for a specific request
> 
> I tried mod_rewrite
> 
> RewriteRule ^/(forbidden_.*) - [R=404]

RewriteRule ^/forbidden_ - [R=404]

should work, but this depends upon your apache version. It's implemented 
since 2.1 I think. You're using this in per-server context (outside of 
<directory>, no .htaccess files), right?

> I would need to redirect to a nonexisting url, so the browser would 
> receive a 301 first and then get the 404,

No, there is another way:

RewriteRule ^/forbidden_ /nonexistent [L]

which would produce a 404 not found, too.

-- 
Robert

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] return 404 for specific url ?

Posted by Richard de Vries <ri...@yahoo.com>.
Hey there, it sounds like you should be able to get
this to work with mod_rewrite ... but either way, you
should have a look at mod_security.
(http://www.modsecurity.org/)

It can do that, and so much more!

  R.


--- peter pilsl <pi...@goldfisch.at> wrote:

> 
> I want to configure a virtual host to return 404 for
> a specific request
> 
> I tried mod_rewrite
> 
> RewriteRule ^/(forbidden_.*) - [R=404]
> 
> but this does not work. Also didnt find anything in
> mod_alias.
> 
> I would need to redirect to a nonexisting url, so
> the browser would 
> receive a 301 first and then get the 404, which is
> not what I need !! 
> The first answer need to be a 404.  I hope there is
> a solution inside 
> apache, otherwise I would need to rewrite my
> application to return 404 
> itself.
> 
> thnx,
> p
> 
>
---------------------------------------------------------------------
> The official User-To-User support forum of the
> Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for
> more info.
> To unsubscribe, e-mail:
> users-unsubscribe@httpd.apache.org
>    "   from the digest:
> users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail:
> users-help@httpd.apache.org
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org