Thread $ENV{SCRIPT_URI}: wann wird die Variable gesetzt? (10 answers)
Opened by macMeck at 2005-12-19 13:45

GwenDragon
 2006-01-25 10:59
#29692 #29692
User since
2005-01-17
14606 Artikel
Admin1
[Homepage]
user image
http://localhost/manual/mod/mod_rewrite.html.en#En...
Quote
Environment Variables
This module keeps track of two additional (non-standard) CGI/SSI environment variables named SCRIPT_URL and SCRIPT_URI. These contain the logical Web-view to the current resource, while the standard CGI/SSI variables SCRIPT_NAME and SCRIPT_FILENAME contain the physical System-view.

Notice: These variables hold the URI/URL as they were initially requested, i.e., before any rewriting. This is important because the rewriting process is primarily used to rewrite logical URLs to physical pathnames.


Zum Test mach doch mal folgendes:
Code: (dl )
RewriteRule ".*index\.html" /cgi-bin/env.pl/$1


Rufe dann mal http://deine.test.domain/index.html auf.
Und was passiert in der Ausgabe des env.pl?

env.pl:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/perl

use strict;

##
##  printenv -- demo CGI program which just prints its environment
##

print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach my $var (sort(keys(%ENV))) {
   my $val = $ENV{$var};
   $val =~ s|\n|\\n|g;
   $val =~ s|"|\\"|g;
   print "${var}=\"${val}\"\n";
}
\n\n

<!--EDIT|GwenDragon|1138180655-->

View full thread $ENV{SCRIPT_URI}: wann wird die Variable gesetzt?