Issue #76824 by geerlingguy, xjm, droplet, kbahey: Change notice for Drupal should not handle 404 for certain files.
parent
bd11d95c33
commit
e120a6e886
|
@ -16,12 +16,6 @@ Options +FollowSymLinks
|
||||||
# Make Drupal handle any 404 errors.
|
# Make Drupal handle any 404 errors.
|
||||||
ErrorDocument 404 /index.php
|
ErrorDocument 404 /index.php
|
||||||
|
|
||||||
# Force simple error message for requests for non-existent favicon.ico.
|
|
||||||
<Files favicon.ico>
|
|
||||||
# There is no end quote below, for compatibility with Apache 1.3.
|
|
||||||
ErrorDocument 404 "The requested file favicon.ico was not found.
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
# Set the default handler.
|
# Set the default handler.
|
||||||
DirectoryIndex index.php index.html index.htm
|
DirectoryIndex index.php index.html index.htm
|
||||||
|
|
||||||
|
|
|
@ -2402,6 +2402,34 @@ function drupal_maintenance_theme() {
|
||||||
_drupal_maintenance_theme();
|
_drupal_maintenance_theme();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a simple 404 Not Found page.
|
||||||
|
*
|
||||||
|
* If fast 404 pages are enabled, and this is a matching page then print a
|
||||||
|
* simple 404 page and exit.
|
||||||
|
*
|
||||||
|
* This function is called from drupal_deliver_html_page() at the time when a
|
||||||
|
* a normal 404 page is generated, but it can also optionally be called directly
|
||||||
|
* from settings.php to prevent a Drupal bootstrap on these pages. See
|
||||||
|
* documentation in settings.php for the benefits and drawbacks of using this.
|
||||||
|
*
|
||||||
|
* Paths to dynamically-generated content, such as image styles, should also be
|
||||||
|
* accounted for in this function.
|
||||||
|
*/
|
||||||
|
function drupal_fast_404() {
|
||||||
|
$exclude_paths = variable_get('404_fast_paths_exclude', FALSE);
|
||||||
|
if ($exclude_paths && !preg_match($exclude_paths, $_GET['q'])) {
|
||||||
|
$fast_paths = variable_get('404_fast_paths', FALSE);
|
||||||
|
if ($fast_paths && preg_match($fast_paths, $_GET['q'])) {
|
||||||
|
drupal_add_http_header('Status', '404 Not Found');
|
||||||
|
$fast_404_html = variable_get('404_fast_html', '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>');
|
||||||
|
// Replace @path in the variable with the page path.
|
||||||
|
print strtr($fast_404_html, array('@path' => check_plain(request_uri())));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return TRUE if a Drupal installation is currently being attempted.
|
* Return TRUE if a Drupal installation is currently being attempted.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -2476,6 +2476,9 @@ function drupal_deliver_html_page($page_callback_result) {
|
||||||
|
|
||||||
watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
|
watchdog('page not found', check_plain($_GET['q']), NULL, WATCHDOG_WARNING);
|
||||||
|
|
||||||
|
// Check for and return a fast 404 page if configured.
|
||||||
|
drupal_fast_404();
|
||||||
|
|
||||||
// Keep old path for reference, and to allow forms to redirect to it.
|
// Keep old path for reference, and to allow forms to redirect to it.
|
||||||
if (!isset($_GET['destination'])) {
|
if (!isset($_GET['destination'])) {
|
||||||
$_GET['destination'] = $_GET['q'];
|
$_GET['destination'] = $_GET['q'];
|
||||||
|
@ -2492,7 +2495,7 @@ function drupal_deliver_html_page($page_callback_result) {
|
||||||
if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
|
if (empty($return) || $return == MENU_NOT_FOUND || $return == MENU_ACCESS_DENIED) {
|
||||||
// Standard 404 handler.
|
// Standard 404 handler.
|
||||||
drupal_set_title(t('Page not found'));
|
drupal_set_title(t('Page not found'));
|
||||||
$return = t('The requested page could not be found.');
|
$return = t('The requested page "@path" could not be found.', array('@path' => request_uri()));
|
||||||
}
|
}
|
||||||
|
|
||||||
drupal_set_page_content($return);
|
drupal_set_page_content($return);
|
||||||
|
|
|
@ -291,9 +291,8 @@ class LocaleTranslationFunctionalTest extends DrupalWebTestCase {
|
||||||
$this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), t('The test language has been removed.'));
|
$this->assertRaw(t('The language %locale has been removed.', array('%locale' => $name)), t('The test language has been removed.'));
|
||||||
// Reload to remove $name.
|
// Reload to remove $name.
|
||||||
$this->drupalGet($path);
|
$this->drupalGet($path);
|
||||||
$this->assertNoText($langcode, t('Language code not found.'));
|
// Verify that language is no longer found.
|
||||||
$this->assertNoText($name, t('Name not found.'));
|
$this->assertResponse(404, t('Language no longer found.'));
|
||||||
$this->assertNoText($native, t('Native not found.'));
|
|
||||||
$this->drupalLogout();
|
$this->drupalLogout();
|
||||||
|
|
||||||
// Delete the string.
|
// Delete the string.
|
||||||
|
|
|
@ -428,6 +428,42 @@ ini_set('session.cookie_lifetime', 2000000);
|
||||||
# 'a.b.c.d',
|
# 'a.b.c.d',
|
||||||
# );
|
# );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fast 404 pages:
|
||||||
|
*
|
||||||
|
* Drupal can generate fully themed 404 pages. However, some of these responses
|
||||||
|
* are for images or other resource files that are not displayed to the user.
|
||||||
|
* This can waste bandwidth, and also generate server load.
|
||||||
|
*
|
||||||
|
* The options below return a simple, fast 404 page for URLs matching a
|
||||||
|
* specific pattern:
|
||||||
|
* - 404_fast_paths_exclude: A regular expression to match paths to exclude,
|
||||||
|
* such as images generated by image styles, or dynamically-resized images.
|
||||||
|
* If you need to add more paths, you can add '|path' to the expression.
|
||||||
|
* - 404_fast_paths: A regular expression to match paths that should return a
|
||||||
|
* simple 404 page, rather than the fully themed 404 page. If you don't have
|
||||||
|
* any aliases ending in htm or html you can add '|s?html?' to the expression.
|
||||||
|
* - 404_fast_html: The html to return for simple 404 pages.
|
||||||
|
*
|
||||||
|
* Add leading hash signs if you would like to disable this functionality.
|
||||||
|
*/
|
||||||
|
$conf['404_fast_paths_exclude'] = '/\/(?:styles)\//';
|
||||||
|
$conf['404_fast_paths'] = '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|asp)$/i';
|
||||||
|
$conf['404_fast_html'] = '<html xmlns="http://www.w3.org/1999/xhtml"><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* By default, fast 404s are returned as part of the normal page request
|
||||||
|
* process, which will properly serve valid pages that happen to match and will
|
||||||
|
* also log actual 404s to the Drupal log. Alternatively you can choose to
|
||||||
|
* return a 404 now by uncommenting the following line. This will reduce server
|
||||||
|
* load, but will cause even valid pages that happen to match the pattern to
|
||||||
|
* return 404s, rather than the actual page. It will also prevent the Drupal
|
||||||
|
* system log entry. Ensure you understand the effects of this before enabling.
|
||||||
|
*
|
||||||
|
* To enable this functionality, remove the leading hash sign below.
|
||||||
|
*/
|
||||||
|
# drupal_fast_404();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authorized file system operations:
|
* Authorized file system operations:
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue