You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Luis Fernando <lu...@task.com.br> on 2009/10/26 14:11:35 UTC

[users@httpd] same rewrite for several vhosts on 404 errors

Hello guys.

I use apache2 on debian and i have several vhosts in 
/etc/apache2/sites-available, included by /etc/apache/apache2.conf.

Well, i need to redirect requests to all vhosts's non existing documents 
to a specific page.

I already know the needed rule. What i need to know is where to put it, 
because i don't wanna configure it for each vhost.

Is there a way to do it?

Thanks for your help.


Luís Fernando Alén Gonçalves.




---------------------------------------------------------------------
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] same rewrite for several vhosts on 404 errors

Posted by Luis Fernando <lu...@task.com.br>.
Ok, i almost figured it out.

I added the rewrite rule to the server config and inserted these two 
lines on each vhost:

RewriteEngine On
rewriteOptions inherit

It works, but it's not what i want yet...

On apache docs i've read that rewrite configurations aren't inherited by 
default.

/"//Note that, by default, rewrite configurations are not inherited. 
This means that you need to have a |RewriteEngine on| directive for each 
virtual host in which you wish to use it."

/Can someone tell me if that's the better way of doing it, indeed?



Luis Fernando wrote:
> Hello guys.
>
> I use apache2 on debian and i have several vhosts in 
> /etc/apache2/sites-available, included by /etc/apache/apache2.conf.
>
> Well, i need to redirect requests to all vhosts's non existing 
> documents to a specific page.
>
> I already know the needed rule. What i need to know is where to put 
> it, because i don't wanna configure it for each vhost.
>
> Is there a way to do it?
>
> Thanks for your help.
>
>
> Luís Fernando Alén Gonçalves.
>
>
>
>
> ---------------------------------------------------------------------
> 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
>
>
>

---------------------------------------------------------------------
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] same rewrite for several vhosts on 404 errors

Posted by Luis Fernando <lu...@task.com.br>.
André,

I typed it wrong, sorry. Actually, i wanted to type "sites-enable".

And yes, i know all about the "a2ensite" and "a2dissite" commands and 
its interesting features.

Well, maybe i can put it on an include. That's not a bad idea.

But what i still want to avoid is repeating configuration on vhosts.



André Warnier wrote:
> Luis Fernando wrote:
>> Hello guys.
>>
>> I use apache2 on debian and i have several vhosts in 
>> /etc/apache2/sites-available, included by /etc/apache/apache2.conf.
>
> Not really : what is really included, are the files present in 
> /etc/apache2/sites-enabled.  These are symlinks to the files that are 
> in /etc/apache2/sites-available, but you can have files in 
> /etc/apache2/sites-available, which are not really used right now.
> Have a good look at the "a2ensite" command and what it does.
> That is one of the nicest things of the Apache2 configuration process 
> in Debian.
>
>>
>> Well, i need to redirect requests to all vhosts's non existing 
>> documents to a specific page.
>>
>> I already know the needed rule. What i need to know is where to put 
>> it, because i don't wanna configure it for each vhost.
>>
>> Is there a way to do it?
>>
> It would probably be cleaner if you repeated it in each VirtualHost.
> You can do this via an "Include" also, so it is only one configuration 
> file.
>
> There is another way, but in my view it is more confusing and 
> dangerous, because when you look at a VHost configuration, you will 
> not see it, and forget that it happens :
>
> In the principle, anything which you put (or include) in the "main" 
> configuration part, is "inherited" by all VirtualHosts, unless they 
> redefine the same parameter themselves.
> When I say "main" configuration, it means everything that ultimately 
> becomes part of the entire configuration, but is not between 
> <VirtualHost>..</VirtualHost> tags.  That includes apache2.conf, but 
> also all files which are Include-d in it at startup time.
>
> ---------------------------------------------------------------------
> 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
>
>
>

---------------------------------------------------------------------
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] same rewrite for several vhosts on 404 errors

Posted by André Warnier <aw...@ice-sa.com>.
Luis Fernando wrote:
> Hello guys.
> 
> I use apache2 on debian and i have several vhosts in 
> /etc/apache2/sites-available, included by /etc/apache/apache2.conf.

Not really : what is really included, are the files present in 
/etc/apache2/sites-enabled.  These are symlinks to the files that are in 
/etc/apache2/sites-available, but you can have files in 
/etc/apache2/sites-available, which are not really used right now.
Have a good look at the "a2ensite" command and what it does.
That is one of the nicest things of the Apache2 configuration process in 
Debian.

> 
> Well, i need to redirect requests to all vhosts's non existing documents 
> to a specific page.
> 
> I already know the needed rule. What i need to know is where to put it, 
> because i don't wanna configure it for each vhost.
> 
> Is there a way to do it?
> 
It would probably be cleaner if you repeated it in each VirtualHost.
You can do this via an "Include" also, so it is only one configuration file.

There is another way, but in my view it is more confusing and dangerous, 
because when you look at a VHost configuration, you will not see it, and 
forget that it happens :

In the principle, anything which you put (or include) in the "main" 
configuration part, is "inherited" by all VirtualHosts, unless they 
redefine the same parameter themselves.
When I say "main" configuration, it means everything that ultimately 
becomes part of the entire configuration, but is not between 
<VirtualHost>..</VirtualHost> tags.  That includes apache2.conf, but 
also all files which are Include-d in it at startup time.

---------------------------------------------------------------------
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