Forum Moderators: phranque

Message Too Old, No Replies

defined variables list

         

sssweb

4:52 pm on Jun 30, 2010 (gmt 0)

10+ Year Member



Can someone point me to a list that tells what results to expect from using defined variables like

%{SCRIPT_FILENAME}
%{REQUEST_FILENAME}
etc.

I can't find this in the Apache docs.

g1smd

6:48 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The results will vary if you use rewrites or not.

The easiest way is to build a test script and print them out for each request you make.

They should be in the Apache Docs, but the wording needs a careful read; it's not easy to follow.

sssweb

7:27 pm on Jun 30, 2010 (gmt 0)

10+ Year Member



The easiest way is to build a test script and print them out for each request you make.


I actually ended up doing that. Didn't find a variable that gives me exactly what I want, which is the name of the file being requested, without the string of folders that it's in. If you know of one that gives this, can you post; otherwise, is there a simple way to isolate the value from %{REQUEST_URI}?

g1smd

8:38 pm on Jun 30, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Yes, the filename is everything after the final slash.

However, do think about requests for just "/" or "/folder/"- check whether a filename is revealed for those.

jdMorgan

1:27 am on Jul 10, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> what I want, which is the name of the file being requested
Parse SCRIPT_FILENAME, and take everything after the final slash.

In mod rewrite, that would be
 RewriteCond %{REQUEST_FILENAME} ^([^/]+/)+([^/]+)$ 

In this example, the back-reference $2 would contain the filename only.

Note that REQUEST_FILENAME is a mod_rewrite synonym for the cgi variable SCRIPT_FILENAME

Jim