After a2enmod rewrite
, I wrote the file /etc/apache2/conf-available/myspecific_rewrite.conf
:
RewriteEngine on
RewriteRule ^/test(/.*)?$ http://anothersite.tld/test$1 [R]
RewriteRule ^/test2(/.*)?$ http://anothersite2.tld/test [R]
Then I a2enconf myspecific_rewrite
and the correct symbolic link is created in /etc/apache2/conf-enabled
.
The problem is that this conf doesn't work : the rewrite is not active.
I want that rewrite to be active for all my virtual hosts. This file I wrote defines RewriteRule
s outside of a <VirtualHost>
... is there a way to make it working?
you could use
include
in every VirtualHost directive pointing to the file.Source for the info: SO comment by Jeremy Bourque
alternative you can use
on every VirtualHost
Source: same question and Apache Docs for mod_rewrite
Here is what I finally did : using mod_alias's
Redirect
andRedirectMatch
directives.Here is my conf file :
Advantage : I don't need mod_rewrite anymore.