Post by I R A Darth AggieOn Tue, 18 Aug 2015 16:07:46 -0700,
Post by David E. RossPost by DedomenPost by David E. RossPost by DedomenPost by David E. RossI am trying to create my own 404 page. When someone requests a
non-existent Web page from my domain, what environment variable contains
the requested path to the page?
You are using apache, nginx or something else?
Server: Apache/2.2.29
OS: Unix
mod_ssl/2.2.29
OpenSSL/1.0.1e-fips
mod_bwlimited/1.4
mod_perl/2.0.8
Perl/v5.10.1
Sorry for the late answer. Creating custom 404 page is trivial in Apache.
https://www.digitalocean.com/community/tutorials/how-to-create-a-custom-404-page-in-apache
I did all that quite some time ago. Yes, my 404 page does appear when
someone requests a non-existant page.
What I want, however, is to display the path that the visitor requested.
For example, someone might request
http://www.rossde.com/garden/xxyyzz.html
My 404 page already has coded into it
Error at <www.rossde.com>
The next line on the page says
where I would want to see
No Such Web Page: /garden/xxyyzz.html
For that to work, I need the Apache environment variable that contains
the path that was requested.
All this worked with a prior Web host. But that host decided to
eliminate all consumer accounts, focusing only on commercial accounts.
I am very frustrated because my current host does not seem to handle
server-side includes well.
REQUEST_URI: /cgi-bin/environ.pl
----snippy------
#!/usr/bin/perl -- -*-perl-*-
print qq(Content-Type: text/html\n\n<HTML>
<HEAD>
<TITLE>Environmental Variables in CGI</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFF0">
);
foreach $key (sort keys %ENV){
print qq(<strong>$key</strong>: $ENV{$key}<br>\n);
}
print "</body>\n";
----snippy------
Which looks like it gives you precisely what you want.
No, REQUEST_URI does not give me what I want.
Try the following URI, which is a link to a Web page that does not
exist: <http://www.rossde.com/xxyyzz.html>. That displays my page at
<http://www.rossde.com/my404.shtml>.
The top of that page has the title "Error at <www.rossde.com>", where
the domain is hard-coded into the HTML. The subtitle should read "No
Such Web Page: /xxyyzz.html", but instead it has "No Such Web Page:
/my404.shtml". This latter is quite wrong since the Web page at not
only exists but is being displayed.
The markup for the title and subtitle are: <h1>Error at <www.rossde.com></h1>
<h2>No Such Web Page: <!--#echo var="REQUEST_URI" --> </h2>
The Web server information is:
Server: Apache/2.2.29
OS: Unix
Mods:
mod_ssl/2.2.29
OpenSSL/1.0.1e-fips
mod_bwlimited/1.4
mod_perl/2.0.8
Perl/v5.10.1
The permissions on <http://www.rossde.com/my404.shtml> are:
user: read, write, execute
group and "world": read, execute
My .htaccess file contains:
Options +Includes
AddHandler cgi-script .ksh
ErrorDocument 404 http://www.rossde.com/my404.shtml
--
David E. Ross
Why do we tolerate political leaders who
spend more time belittling hungry children
than they do trying to fix the problem of
hunger? <http://mazon.org/>