httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cordente Emmanuel <ECorde...@VOYAGES-SNCF.COM>
Subject RE: [users@httpd] Request_URI and ErrorDocument interaction ?
Date Mon, 11 Sep 2017 11:56:12 GMT
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)

Any idea ?

Emmanuel

-----Original Message-----
From: Yann Ylavic [mailto:ylavic.dev@gmail.com] 
Sent: samedi 9 septembre 2017 21:35
To: users@httpd.apache.org
Subject: Re: [users@httpd] Request_URI and ErrorDocument interaction ?

Hi,

On Wed, Sep 6, 2017 at 1:54 PM, Cordente Emmanuel <ECordente@voyages-sncf.com> wrote:
>
> Why the Request_URI environment variable is change by the 
> ErrorDocument treatment ?

The ErrorDocument handling is an internal redirect which changes the URI internally (hence
REQUEST_URI) and runs the SetEnvIf again...

The original URI is placed in REDIRECT_URL, though.

>
> Is there a way to get the real request path, either with rewriterule 
> and ErrorDocument ?

I'd try something like (untested):

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

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

but there's probably a better way to do it.


Regards,
Yann.

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


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