You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bj <bj...@gmail.com> on 2007/08/21 11:19:15 UTC

[users@httpd] mod_rewrite and VirtualHost

Hi,

I have a problem configuring a server with mod_rewrite and several virtual
hosts.
I have several name based virtual hosts and I want to apply a rewrite rule
to all of them. Typically I want to disable the TRACE method on apache
2.0.52
I've tried to put the rewrite rule in the main server configuration but it
doesn't work and no rewrite logs are generated.

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{REQUEST_METHOD} ^TRACE
  RewriteRule .* - [F]
  RewriteLogLevel 9
  RewriteLog "/var/log/httpd/rewrite_log"
</IfModule>

NameVirtualHost *:80
<VirtualHost *:80>
    ...
    ServerName www.mydomain1.com
    DocumentRoot ...
</VirtualHost>
<VirtualHost *:80>
    ...
    ServerName www.mydomain2.com
    DocumentRoot ...
</VirtualHost>


When I put the rewrite section in the virtual hosts it works.
Is there a way
to have this rewrite rule applied to all my virtual hosts without
having to duplicate this section in each VirtualHost ?

Best regards,

--
Bj

Re: [users@httpd] mod_rewrite and VirtualHost

Posted by Bj <bj...@gmail.com>.
Thanks for the inherit tip. I didn't see it in the rewrite doc.

-- 
Bj

On 8/21/07, Joshua Slive <jo...@slive.ca> wrote:
>
> On 8/21/07, Bj <bj...@gmail.com> wrote:
> > Hi,
> >
> > I have a problem configuring a server with mod_rewrite and several
> virtual
> > hosts.
> > I have several name based virtual hosts and I want to apply a rewrite
> rule
> > to all of them. Typically I want to disable the TRACE method on apache
> > 2.0.52
> > I've tried to put the rewrite rule in the main server configuration but
> it
> > doesn't work and no rewrite logs are generated.
> >
> >  <IfModule mod_rewrite.c>
> >    RewriteEngine On
> >    RewriteCond %{REQUEST_METHOD} ^TRACE
> >    RewriteRule .* - [F]
> >   RewriteLogLevel 9
> >   RewriteLog "/var/log/httpd/rewrite_log"
> > </IfModule>
> >
> >  NameVirtualHost *:80
> > <VirtualHost *:80>
> >     ...
> >     ServerName www.mydomain1.com
> >     DocumentRoot ...
> > </VirtualHost>
> > <VirtualHost *:80>
> >     ...
> >     ServerName www.mydomain2.com
> >     DocumentRoot ...
> > </VirtualHost>
> >
> >
> > When I put the rewrite section in the virtual hosts it works.
> > Is there a way to have this rewrite rule applied to all my
> > virtual hosts without having to duplicate
> > this section in each VirtualHost ?
>
> The direct answer to your question is here:
> http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#vhosts
>
> But note that:
> 1. You are wasting your time disabling TRACE. It is not a security
> vulnerability.
> 2. Modern versions of apache can control the use of TRACE with the
> TraceEnable directive:
> http://httpd.apache.org/docs/2.2/mod/core.html#traceenable
> but you aren't using a modern version of apache.
>
> Joshua.
>
> ---------------------------------------------------------------------
> 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] mod_rewrite and VirtualHost

Posted by Joshua Slive <jo...@slive.ca>.
On 8/21/07, Bj <bj...@gmail.com> wrote:
> Hi,
>
> I have a problem configuring a server with mod_rewrite and several virtual
> hosts.
> I have several name based virtual hosts and I want to apply a rewrite rule
> to all of them. Typically I want to disable the TRACE method on apache
> 2.0.52
> I've tried to put the rewrite rule in the main server configuration but it
> doesn't work and no rewrite logs are generated.
>
>  <IfModule mod_rewrite.c>
>    RewriteEngine On
>    RewriteCond %{REQUEST_METHOD} ^TRACE
>    RewriteRule .* - [F]
>   RewriteLogLevel 9
>   RewriteLog "/var/log/httpd/rewrite_log"
> </IfModule>
>
>  NameVirtualHost *:80
> <VirtualHost *:80>
>     ...
>     ServerName www.mydomain1.com
>     DocumentRoot ...
> </VirtualHost>
> <VirtualHost *:80>
>     ...
>     ServerName www.mydomain2.com
>     DocumentRoot ...
> </VirtualHost>
>
>
> When I put the rewrite section in the virtual hosts it works.
> Is there a way to have this rewrite rule applied to all my
> virtual hosts without having to duplicate
> this section in each VirtualHost ?

The direct answer to your question is here:
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#vhosts

But note that:
1. You are wasting your time disabling TRACE. It is not a security
vulnerability.
2. Modern versions of apache can control the use of TRACE with the
TraceEnable directive:
http://httpd.apache.org/docs/2.2/mod/core.html#traceenable
but you aren't using a modern version of apache.

Joshua.

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