You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by go...@Safe-mail.net on 2015/08/15 20:36:58 UTC

[users@httpd] causes internal redirect

Version: Apache 2.4.10 (Debian Jessy), worker MPM

This works how I expect:

<VirtualHost *:80>
   DocumentRoot /var/www/html
   LogLevel trace8
   RewriteEngine on

   RewriteCond %{REQUEST_URI} ^/dir/file2.html
   RewriteRule .* /var/www/html/file2.html [L]
</VirtualHost>

Debug log: https://pastebin.ca/raw/3107063

It recognizes /var/www/html/file2.html as a local path and serves up that file.

This does not work the same:

<VirtualHost *:80>
   DocumentRoot /var/www/html
   LogLevel trace8
   RewriteEngine on

   <If "1 -eq 1">
      RewriteCond %{REQUEST_URI} ^/dir/file2.html
      RewriteRule .* /var/www/html/file2.html [L]
   </If>
</VirtualHost>

Debug log: https://pastebin.ca/raw/3107064

Adding the <If> causes Apache to treat /var/www/html/file2.html as a URI and now an internal redirect is made, and the request fails (and that is just not what should happen). The <If> expression doesn't matter, any matching expression acts the same. I've tried lots of variations such as [END] and different directories and paths and gotten the same result. The important part is that just adding <If> makes the rewrite act very different.

I'm not looking for an alternative or a workaround, I actually need to know why the <If> causes this to happen. It seems like a bug to me. I haven't tried 2.4.16 but there are no related changelog entries between 2.4.10 and 2.4.16.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] causes internal redirect

Posted by Eric Covener <co...@gmail.com>.
On Sat, Aug 15, 2015 at 2:36 PM,  <go...@safe-mail.net> wrote:
> I'm not looking for an alternative or a workaround, I actually need to know why the <If> causes this to happen. It seems like a bug to me. I haven't tried 2.4.16 but there are no related changelog entries between 2.4.10 and 2.4.16.

RewriteRule substitutions always work that way in per-directory
context because they need to be introduced back into the parts of the
server that has already run by the time it's late enough to process
these.    This includes complicated stuff like peeling off the
documentroot and peeking at the first componnt of the path to see if
it lives on disk.

<If> counts as per-directory like Location and Directory and htaccess.
Anything that isn't global/vhost context is per-dir.

I don't really understand what goes wrong in this case though with the
internal redirect happening.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org