I'm using a custom 404 page (i.e. Admin | Config | System).

A feature I'd like to be able to use:

When the visitor types in www.mydomain.com/splldwrong, I'd like the 404 landing page to say something like:

Sorry, the page you requested, www.mydomain.com/splldwring, could not be found.

I could easily accomplish this if one of the following were true:

1. I could insert a token for the url of the mis-typed page in the field for the Default 404 page, i.e.
node/191/[node:url] (Note: this does not work. The token does not resolve in the url.)

or

2. I could use a token for the mis-typed page in my 404 landing page, i.e.
Sorry, the page you requested, [node:referring_url], could not be found. (Note: this, also, does not work. The token I'm looking for does not exist.)

Comments

dave reid’s picture

Component: token system » base system
Category: feature » support

Default 404 page path does not support tokens at all.

stevengraff’s picture

Thanks for your reply. I solved this as follows:

  1. Created basic page as custom 404 page.
  2. Used this code to display the errant path in the message to the visitor:
<?php echo "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']  ; ?>

Followed by another little code snippet that redirects to my home page after a few seconds.

You can see it all work by going to http://www.plain-english.com/xyzzy

Today I stumbled across the Search 404 module... it looks like that may have given me what I was looking for also.

Version: 7.14 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.