Reputation: 333
I suspect this can't be done, but here goes anyway. Is there a way, on a static site, to show the URL the user is trying to reach when you use the Apache directive ErrorDocument to redirect a 404 File Not Found error to a custom page? For instance, if you try:
http://www.fredriley.org.uk/dingbat/arsebiscuits
the default 404 error says:
The requested URL /dingbat/arsebiscuits was not found on this server.
So the URL must be in an environment variable. Can I get at that in a custom error document? I'd like to tell users the URL rather than just give them a generic error document. I know I can do this easily enough in PHP, but the site comprises static HTML docs only.
Upvotes: 1
Views: 819
Reputation: 146660
Having a static site does not prevent you from having a dynamic error page. You can use whatever server-side technology your hosting service offers.
If you can use PHP, you can simply pick a static template, change its extension to *.php
and add a little dynamic snippet:
<p><?php echo htmlspecialchars($_SERVER['REQUEST_URI']); ?></p>
If you can use SSI, it's very similar:
<p><!--#echo var="REQUEST_URI" --></span></p>
The REQUEST_URI
variable contains the local part of the URL as typed by the user (except hash). It's a good choice.
Upvotes: 1