RewriteCond %{PATH_TRANSLATED}\%1\%2\%3\%4\%5.htm !-f is not working?

Topics: Developer Forum
Aug 20, 2008 at 2:07 AM

Hi,

Soon as I started to use the version 2.0, I'm getting a wierd behavior, the "RewriteCond %{PATH_TRANSLATED}\%1\%2\%3\%4\%5.htm !-f" is returning TRUE, even when the file is there...

I think the Condition is not converting the it's data based at %{} and the %1 from the match...

I did something wrong? It was working 100% fine with the last version... and I'll downgrade it now...

# /agu/2007/jun/11/pgu_divulga_resultado_da_consulta_geral_para
RewriteCond %{HTTP_URL}            ^/(\w+)/(\d+)/(\w+)/(\d+)/([^.]+)$
RewriteCond %{PATH_TRANSLATED}\%1\%2\%3\%4\%5.htm   !-f
RewriteRule (?i)^(/\w+/\d+/\w+/\d+)(/[^.]+)$ /OMRedirect.asp?p=10&d=$1&f=$2&WebPublisher=1 [U,L]

/agu/2007/jun/11/pgu_divulga_resultado_da_consulta_geral_para
RewriteCond %{HTTP_URL}            ^/(\w+)/(\d+)/(\w+)/(\d+)/([^.]+)$
RewriteCond %{PATH_TRANSLATED}\%1\%2\%3\%4\%5.htm   -f
RewriteRule (?i)^(/\w+/\d+/\w+/\d+)(/[^.]+)$ $1$2.htm [U,L]

Coordinator
Aug 20, 2008 at 6:51 PM
Edited Aug 21, 2008 at 12:10 AM

2 things:

A.  I changed the default "back reference" marker character from '%'  to '*' in v2.0.  this was because % was overloaded in meaning.  Using % as the marker character, it was not possible to distinguish between URL-escaped sequences (like %2f) and back-references (like %2).   So by default, the character is * (Asterisk) in v2.0.  You can switch it back to % by using this directive in your ini file:

  CondSubstringBackrefFlag %

Or, you could replace the %1 %2 %3 etc with *1 *2 *3 , and so on.
That directive also works in v1.2.15, but the default marker character is % in v1.2.15, whereas it is * in v2.0. 


B. Do you have a logfile of the thing that is not working?   Because in my IIRF, the string like %{PATH_TRANSLATED}\%1\%2\%3\%4\%5.htm gets evaluated to <vroot>\agu\2007\jun\11\pgu_divulga_resultado_da_consulta_geral_paras\agu\2007\jun\11\pgu_divulga_resultado_da_consulta_geral_paras.htm.

In other words, the PATH_TRANSLATED seems to be redundant with all of the itemized back references. I don't really get how this would ever work. 

After you make the change from A, can you send me a logfile showing what is happening for you? 

 

Aug 21, 2008 at 7:20 AM

Hi,

I'll do some tests and I'll inform the result...

Also, I'll send the log result.

The %{PATH_TRANSLATED}\%1\%2\%3\%4\%5.htm  works fine here... I don't know yours have a different result...

Let's see the new tests...

Ahh... the web site that .INI file is working, is the www.direito2.com.br. I'm using a lot your software...

Best,

Ruben

Coordinator
Aug 21, 2008 at 12:31 PM

Also, Zevallos, have you understood PATH_TRANSLATED clearly? 

according to http://blogs.msdn.com/david.wang/archive/2005/08/04/What-is-PATH-TRANSLATED.aspx, these are some server variables you should know:

PATH_INFO 

The extra path information, as given by the
client. In other words, scripts can be accessed by
their virtual pathname, followed by extra
information at the end of this path. The extra
information is sent as PATH_INFO. This information
should be decoded by the server if it comes from a
URL before it is passed to the CGI script.

PATH_TRANSLATED 

The server provides a translated version of
PATH_INFO, which takes the path and does any
virtual-to-physical mapping to it.  This gets set
only if PATH_INFO is set!

SCRIPT_NAME 

A virtual path to the script being executed, used
for self-referencing URLs.

And finally, on IIS6 there is SCRIPT_TRANSLATED, which may be what you really want.