[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Apache2, mod_rewrite y redirect





2010/3/22 Marc Aymerich <glicerinu@gmail.com>
Buenas Listeros!!

Tengo un servidor web con un monton de redirecciones usando las directivas redirect y redirectMatch. Pero hoy me he visto obligado a usar el modRewrite para hacer algunas redirecciones condicionales. El problema que tengo es que parece que el modrewrite tiene más prioridad que las directivas redirect y redirectmatch.

Si por ejemplo tengo esta definicion de virtualhost:

<VirtualHost *:80>
 [...]
Redirect /lollypop http://lollipop.com
 [...]
RewriteEngine on
RewriteRule /lollipop http://example.org
</VirtualHost>

Resulta que siempre se me redirige a http://example.org y núnca a http://lollipop.com, a pesar de que la segunda opción aparece antes en el virtualhost. Es normal este comportamiento? hay alguna forma de que el apache ejecute las directivas por el orden en que aparecen?

saludos y graciaS!!
--
Marc

Parece que la mejor solución es pasarlo todo a modrewrite, Os pongo lo que me ha comentado Bertrand de debian-isp:

On Mon, Mar 22, 2010 at 07:20:56PM +0100, Marc Aymerich wrote:
> I have an apache2.15 with a lot of redirections using redirect and
> redirectmatch directives. Today I write some mod_rewrite rules (because I
> need some conditional redirections). I put this new rewrite directives after
> my old redirect and redirectmatch rules, just at the end of the virtualhost
> definition, because I expect that apache execute first my old definitions,
> and then my new rewrite rules. But apache execute the mod_rewrite rules in
> the first place!
[...]
> There are any way to change this behavior?

No.  mod_rewrite translates names at APR_HOOK_FIRST but mod_alias at
APR_HOOK_MIDDLE.  So, whatever order your modules are loaded, you'll get
rewrite rules to be evaluated before any mod_alias translation.




Reply to: