changed into a custom page by adding the following text to the. htaccess file:ErrorDocument errornumber/file.htmlFor example, if I have a notfound.html file under my root directory, I want to use it as a page for 404 error:ErrorDocument 404/notfound.htmlIf the file is not in the root directory of the site, you only need to set the path to:ErrorDocument 500/errorpages/500.htmlNote the path to the error page must be correct, otherwise it may appear: Additionally, a 404 Not Found error is encounte
condition, which supports the regular. The meaning is not equal, this sentence means: If http_host is not www.example.com. The following [NC] (no case) indicates ignoring casing, and common
L (last): Terminates a series of Rewritecond and Rewriterule
R (redirect): Triggers a displayed jump, or you can specify a jump type, such as [r=301]
F (Forbidden): Disable viewing of specific files, Apache will trigger 403 error
Typical applications Picture anti-theft chain Rewriteco
To create a new file EmptyAction.class.php in the action, the code in the file is as follows:
The code is as follows
Copy Code
Class Emptyaction extends action{function _empty () {Header ("http/1.0 404 Not Found");//make HTTP return 404 status Code$this->display ("public:404");}}?>
Set in Apache
Add ErrorDocument 404/404.html to your site configuration.
Set in IIS
Iis/asp.net Set 404 Error page
Open the Apach
As a top priority for the configuration and management of Apache servers, Apache server directives are very important, as we all know. Here is a detailed introduction to the Apache command set, named Apache Command Encyclopedia, I hope to be able to help you work and study! Specific content:
Basic instructions
First, general configuration commands
1, Accessfilename
Default value: Accessfilename. htaccess
This command is the name of the access control file for the directory;
2, Bindaddress
.html "-" Click OK to exit and then upload the err404.html page to the site root directory. In message type here, be sure to select file or default, rather than URL, which will result in the return of a "200" status code.
3.404 point to a dynamic page, such as error.asp, if not set inside the page, just return the hint of the HTML code, will cause the page to return 200 status code, which is not true, we can after the content of the prompts, add the statement: response.status= "404 Not Found" e
this IP in the ip.txt generated by the PHP program above:
104.194.16.230 (USA)
2. Shielding IP
Add the following code to the htaccess:
Deny from 104.194.16.230
When you once again use the mirror website to visit your site will be reported 4.3 errors, now Baidu even included this site on your site will not have any impact
If your server is a Windows server is to block IP on it, if the site uses CDN need to let the CDN official technology to help you shield it.
3. Anti-system
find the relevant information on the Internet.2, then build the directory structure of the websiteThe contents of the. htaccess file for the root directoryRewriteengine onRewriterule ^$ public/[L]Rewriterule (. *) public/$1 [L]The contents of the. htaccess file for the public directoryOptions-multiviewsRewriteengine onOptions-indexesRewritecond%{request_filename}!-dRewritecond%{request_filename}!-fRewritecond%{request_filename}!-lRewriterule ^ (. *) $ index.php?url=$1 [qsa,l]
The DocumentRoot is located under/var/www/html to access However, the DocumentRoot is located in a different directory (for example,/webroot) and forbidden is present. The relevant part of the./etc/httpd/conf/httpd.conf is this: Alias/query "/home/query" Options Indexes MultiViews AllowOverride None Order Allow,deny Allow from all However, when you enter: http://localhost/query/in the browser, the forbidden appears: Forbidden You don't have permission to access/query on this server. Additional
.
For URL rewrite, you need to set the directory at least
Copy code code as follows:
AllowOverride FileInfo
2. Enable the Options followsymlinks and allowoverride all in directories to support URL Rewirte
Copy code code as follows:
alias/php "c:/web/php/"
Options Indexes FollowSymLinks
AllowOverride All
Order Allow,deny
Allow from all
When this is accessed through http://localhost:8080/php/, the/php/and the subdirectories underneath it will support the URL rewrite
1 authconfig
. htaccess action.
The code is as follows
Copy Code
Order Allow,denyDeny from 92.241.169Allow from all
htaccess prohibit IP of the words directly to an IP, prohibit IP paragraph is: Deny from 92.241.169. (92.241.169.1-92.241.169.254)
The effect is to access the display:
Forbidden
You don ' t have permission to access/on this server.
Additionally, a 403 Forbidden error is encountered while trying to the request of a
above text;
Then upload to your site root directory;
Modify your. htaccess file to write code: ErrorDocument 404/404.html.Cases:Rewriteengine onErrorDocument 404/404.html
Note the point:
404 page, do not jump directly to the homepage, but to guide the user to click Back to the Home page. The consequence is, which could lead to the homepage being k;
/404.html front not with the main domain name, no return of the status code is 302
Through the. htaccess settings you can: Implement folder password protection, redirect, custom error page, change your file name extension, url rewrite, block IP, prohibit directory list, prohibit directory running a type of file, modify default directory files, and so on a series of functions.
Use the Script Editor, such as notepad++, VIM, editplus, etc. to create a new (. htaccess) file, note that this file is hidden under Linux by default, you need to set the FTP display hidden files to see
Content Length Required412 Precondition Failed413 Request Entity Too Long414 Request URI Too Long415 Unsupported Media TypeCommon Server error return code:Internal Server Error
Users can use. htaccess to specify their own prepared Error alert page. In general, people can set up a directory specifically, such as errors to place these pages. And then again. htaccess, add the following instructions:ErrorDocument 404/errors/notfound.html
ErrorDocument 50
Phenomenon: This machine with localhost can normally access Wamp's homepage and phpmyadmin, but cannot access through IP address (such as: 192.168.0.231)
Visit Http://192.168.0.231/phpmyadmin, which prompts you for don ' t have permission to access/phpmyadmin/on this server.
Solve:
Open D:\wamp\alias\phpmyadmin.conf
Modify
Options Indexes followsymlinks execcgiAllowOverride AllOrder Deny,allowDeny from allAllow from 127.0.0.1Allow from:: 1Allow from localhost
For
Options Indexes followsymlinks e
? "": "?" + querystring); URL = url.replaceall ("amp;", ""). ReplaceAll ("", "amp;");
%>if (StatusCode = = 404) {%> Sorry, you have not found the address of the page you visited, please contact the administrator to resolve this issue .}else {%> Sorry, the page you visited has a little internal problem, please }%>private static final Org.apache.commons.logging.Log LOGGER = Org.apache.commons.logging.LogFactory.getLog ("Page_ Errors ");%>
Output format for error messages
Similar to:
Error 08/10/
file is over 100KB, speed limit 10KB
# below 510 pretty good, if not set, Apache itself will report an error, on the root of the 404 almost, the page is very ugly
errordocument 510/exceed_speed.html
bandwidtherror 510
maxconnection All #所有ip最大连接数为10
maxconnection 192.168.1.5 5 #192.168.1.5 Maximum number of connections is 5
Test:Before using the Mod_bw.so module:
After using the Mod_bw.so module:
Issues tha
be opened in httpd.conf, and finally, to begin. Htaccess support requires httpd.conf configuration prevents. htaccess files from being downloaded, some basic configuration methods are not complete, and more can be referenced by other Web sites specifically for. htaccess configuration methods.
1. Customizing the default document for a directory
DirectoryIndex index.html index.php index.htm2. Custom error page
ErrorDocument 404 errors/404.html3. Con
allowoverride authconfig parameters (add # or erase)
The reason for doing so
1. I feel trouble (each directory requires a. htaccess file, and the file name that starts with \ ". \" is not allowed under Windows system. )
2. Not very safe (it may be seen.) )
How do you verify the directory you want to specify?
A column child
AuthType Basic//mode, Windows does not support MD5, so please use the basic method
AuthName TEST//Definition Display in dialog box field name
AuthUserFile d:/apache/user//Def
From security considerations, the allowoverride properties of the root directory are generally configured to disallow No Override, that is,
AllowOverride None
When AllowOverride is set to None, the. htaccess file is completely ignored. When this directive is set to all, all directives with the ". htaccess" Scope are allowed to appear in the. htaccess file.
For URL rewrite, you need to set the directory at least
AllowOverride FileInfo
Parameters for allowoverride:
Authconfig
Allow the use of
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.