httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yann Ylavic <ylavic....@gmail.com>
Subject Re: [users@httpd] Request_URI and ErrorDocument interaction ?
Date Mon, 18 Sep 2017 07:50:55 GMT
Sorry for the delay, I missed your response.

On Mon, Sep 11, 2017 at 1:56 PM, Cordente Emmanuel
<ECordente@voyages-sncf.com> wrote:
> Thank you for the proposition, I tried  it without success.
>
> I've used:
> RewriteCond %{ENV:REDIRECT_URL} ^(.+)$
> RewriteRule ^ - [E=originalPath:%1]
>
> RewriteCond %{ENV:originalPath} ^$
> RewriteRule ^ - [E=originalPath:%{REQUEST_URI}]
>
> ErrorDocument 404 /pagenotfound
>
> In the rewrite log I see something strange:
>  [11/Sep/2017:13:27:18 +0200] [myvhost/sid#1df93xx][rid# 7f98e8154870/initial] (5) setting
env variable 'originalPath' to '/nothing'
>  [11/Sep/2017:13:27:18 +0200] [myvhost/sid#1df93xx][rid# 7f98e80aced8/initial/redir#1]
(5) setting env variable 'originalPath' to '/pagenotfound'
>
> The 1st line is what we wanted, but I don't understand the second line.
> It's like the internal redirect of the ErrorDocument run again the rewrite rule like
if it is a brand new request in another context (without the env variable defined before)

Yes, the internal redirect "restarts" the request processing, hence
rewrite rules too.
I missed that REDIRECT_URL was defined in CGI context only, the
general scheme for redirects is that env variables from the previous
request are prefixed with "REDIRECT_".

>
> Any idea ?

Given that, maybe the below?

RewriteCond %{ENV:originalPath} ^$
RewriteRule ^ - [E=originalPath:%{REQUEST_URI}]

RewriteCond %{ENV:REDIRECT_originalPath} ^(.+)$
RewriteRule ^ - [E=originalPath:%1]


Regards,
Yann.

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


Mime
View raw message