Apache Force 404 Error
Contents |
Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn apache tomcat 404 error more about hiring developers or posting ads with us Server Fault Questions Tags Users Badges
Apache 404 Error Page
Unanswered Ask Question _ Server Fault is a question and answer site for system and network administrators. Join them; it only takes a apache 404 error on a file that exists minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top How do I configure the default virtual host return a 404 header
Apache 404 Error Log
in apache? up vote 10 down vote favorite 3 I know that similar questions have been asked, but the available answers are not very clear, so please bear with me. After setting up a few
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn
Apache Tomcat 404 Error The Requested Resource Is Not Available
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Apache Custom 404 Error Page
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, apache 403 error helping each other. Join them; it only takes a minute: Sign up Using mod_rewrite to return 404 for all requests on http [closed] up vote 1 down vote favorite 1 I am configuring apache to create a http://serverfault.com/questions/231438/how-do-i-configure-the-default-virtual-host-return-a-404-header-in-apache site that will use mod_jk to connect to an app running on tomcat. I only want https requests to access my app and I would like to use mod_rewrite to return a 404 for any http request on port 80. Here is my attempt at a VirtualHost configuration
generic error responses in the event of 4xx https://httpd.apache.org/docs/2.4/custom-error.html or 5xx HTTP status codes, these responses are rather stark, https://sites.google.com/site/onlyvalidation/page/force-a-404-or-410-using-the-htaccess-file-on-apache-server uninformative, and can be intimidating to site users. You may wish to provide custom error responses which are either friendlier, or in some language other than English, or perhaps which are styled more in line with your site layout. Customized error 404 error responses can be defined for any HTTP status code designated as an error condition - that is, any 4xx or 5xx status. Additionally, a set of values are provided, so that the error document can be customized further based on the values of these variables, using Server Side Includes. Or, you can apache 404 error have error conditions handled by a cgi program, or other dynamic handler (PHP, mod_perl, etc) which makes use of these variables. Configuration Available Variables Customizing Error Responses Multi Language Custom Error Documents See alsoComments Configuration Custom error documents are configured using the ErrorDocument directive, which may be used in global, virtualhost, or directory context. It may be used in .htaccess files if AllowOverride is set to FileInfo. ErrorDocument 500 "Sorry, our script crashed. Oh dear" ErrorDocument 500 /cgi-bin/crash-recover ErrorDocument 500 http://error.example.com/server_error.html ErrorDocument 404 /errors/not_found.html ErrorDocument 401 /subscription/how_to_subscribe.html The syntax of the ErrorDocument directive is: ErrorDocument <3-digit-code>
module enabled, using the .htaccess file. Add these directives (adjusted for your particular situation): RewriteEngine on ## list uris which are supposed to return 404 are rewritten to a non-existent url which returns a 404 anyway - the server is supposed to respond with a 404** RewriteRule ^(.*)/path-to/url-of-bad-page-i-want-to-see-gone-forever\.html$ http://www.example.com/nonexistent-file-which-gives-404.php ## list uris which are supposed to return 410 RewriteRule ^(.*)/path-to/url-of-bad-page-i-want-to-see-gone-forever\.html$ - [G] ## custom error documents - note that you use only their uri - relative to the root (/) - NEVER use the fully qualified url with http://www.exampe.com/ part. ErrorDocument 404 /error-404.php ErrorDocument 410 /error-410.php **In cases when the server does not respond with a 404 naturally for a non-existent file, then make a php script called nonexistent-file-which-gives-404.php containing this code in it: Even though the file exists, it responds with a 404 - so as far as the server is concerned and any user agent checking the response, it does not exist. How to force a 404 or 410 for a url containing a query string you don't want to allow This is similar to how we strip off a query string except we serve a custom 404 (or 410) error page and respond with a 404 (or 410). Useful for sites that have been hacked (and subsequently unhacked) when you want to ensure all the spammy urls formed with various query strings that your site otherwise doesn't use and created during the hack will respond with 404 or 410. In this example there are 3 query string parameters parm1 through parm3 that may be used together in any order in a query string which make it an undesirable url. We want to respond with 404. RewriteEngine on RewriteCond %{QUERY_STRING} (^|&)parm1= [NC] RewriteCond %{QUERY_STRING} (^|&)parm2= [NC] RewriteCond %{QUERY_STR