Hi Torsten,

? It seems to work fine for the subrequest (status=200) ...?

This is exactly the problem. The 404 is normally generated in the response phase from the default response handler. The subreq lookup won't check that. It does not run the subreq but only checks if after fixup there is still no error.

Hmm... Would that mean that the example receipt in the rewrite guide simply doesn't work as given/explained ? For no one ...?!

So the simplest solution for you would be an ErrorDocument I think.

Something like this:

ErrorDocument 404 /-/404  <- put an url here you are not using otherwise
RewriteRule ^/-/404 http://...%{REDIRECT_URI} [P]

Write a simple printenv and activate it as ErrorDocument first to get
the right environment variable names (not sure if it is REDIRECT_URI).
If you use mod_include that would be

 <!--#printenv -->

in an .shtml file.

I must do something wrong again. Outcommenting RewriteEngine and setting

ErrorDocument 404 /404.shtml

with 404.shtml contaiining the above <!--#printenv --> shows
[...]
REDIRECT_URL=/404.xxx
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1 REQUEST_METHOD=GET
QUERY_STRING=
REQUEST_URI=/404.xxx SCRIPT_NAME=/404.shtml DATE_LOCAL=Monday, 23-Mar-2009 19:49:31 EET DATE_GMT=Monday, 23-Mar-2009 17:49:31 GMT
LAST_MODIFIED=Monday, 23-Mar-2009 19:30:26 EET
DOCUMENT_URI=/404.shtml
DOCUMENT_NAME=404.shtml

(Nothing like REDIRECT_URI).

So I believe it is actually REQUEST_URI I'm after ?

Now, re-enabling the RewriteEngine and setting

    ErrorDocument 404 /-/404

    RewriteLog /tmp/REWRITE.log
    RewriteLogLevel 99

    RewriteEngine on
    RewriteRule ^/-/404 http://OLD_SITE.COM%{REQUEST_URI} [P]

brings me the _error_ page of the old site, and the rewrite log for my http://ACTUAL_SITE.COM/index.php looks like

[rid#2b5dc09e5c68/initial] (2) init rewrite engine with requested uri /index.php
[rid#2b5dc09e5c68/initial] (3) applying pattern '^/-/404' to uri '/index.php'
[rid#2b5dc09e5c68/initial] (1) pass through /index.php
[rid#2b5dc09e4d48/initial/redir#1] (2) init rewrite engine with requested uri 
/-/404
[rid#2b5dc09e4d48/initial/redir#1] (3) applying pattern '^/-/404' to uri 
'/-/404'
[rid#2b5dc09e4d48/initial/redir#1] (2) rewrite '/-/404' -> 
'http://OLD_SITE.COM/-/404'
[rid#2b5dc09e4d48/initial/redir#1] (2) forcing proxy-throughput with 
http://OLD_SITE.COM/-/404
[rid#2b5dc09e4d48/initial/redir#1] (1) go-ahead with proxy request 
proxy:http://OLD_SITE.COM/-/404 [OK]

Still not there yet, not sure how I could get what you mean by REDIRECT_URI.

This solution should work for GET/HEAD. POST requests are still a
problem. If you use them we'll make it work without ErrorDocument.

I'm not sure if POSTs are used, that would be the next step then.

BTW, why don't you use the file lookup (-f). That is much easier. Is your uri->file mapping so complicated?

I'd say yes, it's some CMS in the back and almost all of the content is dynamic, most requests look like

http://MYDOAMIN.COM/index.php?qs_sect_id=3456 etc.

Many thanks,

Iosif Fettich

Reply via email to