One of the common errors on the Web is an invalid link. Once an invalid link appears from another site, you will rearrange your
's site. People will save their favorite sites in a book, and if they visit again after three months, only the ' 404 Not Fount ' will be found.
will not give them task help, tell them how to find the original information from your site. Let's solve this problem, or at least
Give your users a friendly help and get some traces if they encounter a ' a 404 ' error. You can
you'd like to keep the file or open it directly. If you don't want to see this, you can put the following piece of code in your. htaccess file.
Addtype?application/octet-stream?. Pdf
Addtype?application/octet-stream?. Zip
Addtype?application/octet-stream?. mov
4. Omit WWW prefixesOne of the principles of SEO is to make sure that your site has only one URL. Therefore, you need to turn all the access through the WWW to non-www, or reverse this.
Rewriteengine? On
Method one: ". htaccess file Configuration 404" Most of the solutions are: first you have to open the Apache Rewrite_module module, support. htaccess, and then create the. htaccess file (or already exist) in the Web root directory, plus this sentence ErrorDocument 404/404.html can be.But I tried several times and couldn't solve it. Method Two: "Apache server-side perfect solution" in the service profile (/conf/httpd.conf) found
error occurs (for example, automatically Email you when the page cannot be found ).
You can add the following text to the. htaccess file to convert any page error code you know (such as page 404 cannot be found) to a custom page:
ErrorDocument errornumber/file.html
For example, if my root directory contains a notfound.html file, I want to use it as the 404 error page:
ErrorDocument 404/notfound.html
If the
personalized error page (for example, when a file cannot be found ), instead of the error pages provided by your service provider or without any pages. This will make your website look more professional when an error occurs. You can also use the script program to notify you when an error occurs (for example, if I use the free webmaster help PHP script program, I will automatically email it to me when the page cannot be found ).You can use custom error pages for any error as long as you know its
-- With-zlib-Dir =/usr/lib-- With-FreeType-Dir =/usr/local/FreeTypeThis is the configuration option for PHP to support the GD library
Execute make to install# Make; make install
Step 4: Configure httpd. conf to enable Apache to support PHP# Vi/usr/local/Apache/CONF/httpd. confAfter PHP is installed, the following line is automatically added to httpd. conf (if not, add it manually ):Loadmodule php5_module modules/libphp5.so
Find addtype application/X-gzip. GZ. tgz and add the following cont
Htaccess is a convenient pseudo-static rule for friends who do not have server permissions or have one server running N sites.
. Htaccess sets the default homepage order of a website
Add the following lines to the. htaccess file:
The Code is as follows:
Copy code
DirectoryIndex index.html index.htm index. php
How to set the 404 error page in htaccess
Setting the 404 error page for Apache Server is simple. You only need to add the following code to the. htaccess fil
display jump, or you can specify a jump type, such as [r=301]F (Forbidden): Prohibit viewing of specific files, Apache will trigger 403 errorTypical applications
Picture anti-theft chain
The code is as follows
Copy Code
Rewritecond%{http_referer}!^$Rewritecond%{http_referer}!^http://(www.)? example.com/[NC]Rewriterule. (gif|jpg|png) $-[F]
Because it is based on http_referer verification, so can only prevent the general picture hotlinking, because Http_ref
The title has been said to be more clear, only for this kind of situation, want to give people who encounter the same problem a little inspiration, shorten the time to solve the problem.
Related information:
Million network exclusive host/linux operating system/apache/ecshop Mall/404 page settings, also in the Win7 system/apache above also tested through
a problem-solving method:1, first in the Apache Conf directory configuration httpd.conf file, find #er
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.htmlErrorDocument 500/errors/internalerror.html
A single line of instructions. The first instruction above means that the page is displayed as a notfound.html page in the/errors directory for 404, which is when the required document is not found. It is no
. 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.htmlErrorDocument 500/errors/internalerror.html
A single line of instructions. The first instruction above means that the page is displayed as a notfound.html page in the/errors directory for 404, which is when
all its subdirectories. As a user, the commands you can use are limited. Administrators can set up by using Apache's allowoverride directives. Directives in subdirectories overwrite instructions in higher-level directories or primary server configuration files.
I. Locating the wrong document
(1) Common client request error return code:
401 Authorization Required 403 Forbidden 404 Not Found 405 Method not
allowed
408 Request Timed out
4 One Content Length Required
412 precondition Failed
), In the win system is not directly through the "new" file to create, but we can use the copy in CMD to implement, such as Copy Sample.txt. htaccess. You can also create a htaccess.txt, and then FTP to the server, through FTP to modify the file name.
. One application of htaccess is
Custom error page
Custom error pages, which will allow you to have your own, personalized error page (for example, when you can't find a file), not your service provider's error page or no page. This will make yo
an upgrade page
Rewriteengine on
Rewritecond%{request_uri}!/upgrade.html$
Rewritecond%{remote_host}!^24\.121\.202\.30
Rewriterule $ http://www.nbphp.com/upgrade.html [r=302,l] 4.3 turn old domain name to new domain name
# REDIRECT from old domain to new domain
Rewriteengine on
Rewriterule ^ (. *) $http://www.yourdomain.com/$1[r=301,l] 5, some other function 5.1 directory that leads to the wrong document
ErrorDocument 400/errors/badrequest.html
, personalized error page (for example, when you can't find a file), not your service provider's error page or no page. This will make your site look more professional when it goes wrong. You can also use a script to notify you when something is wrong (such as automatically email you when a page is not found).
Any page error code you know (like 404 can't find a page) can be made into a custom page by adding the following text to the. htaccess file:
ErrorDocu
(for example, automatically Email you when the page cannot be found ).
You can add the following text to the. htaccess file to convert any page error code you know (such as page 404 cannot be found) to a custom page:
ErrorDocument errornumber/file.html
For example, if my root directory contains a notfound.html file, I want to use it as the 404 error page:
ErrorDocument 404/notfound.html
If the file is not
in a few cases, they do not allow you to use. htaccess ). The best way is to upload your own. htaccess file to see if it is useful, or directly consult your host service provider.What can a. htaccess file do?. The htaccess file can do a lot of things, including: folder password protection, automatic user redirection, custom error pages, users who change your file extension, ban specific IP addresses, users who only allow specific IP addresses, and list of prohibited directories, and use other f
The way to set the 404 error page for Apache server is simple: Just add the following in the. htaccess file.
The code is as follows
Copy Code
ErrorDocument 404/notfound.php
Attention:1. Remember not to turn the 404 error to the homepage of the website, otherwise it may cause the homepage to disappear in the search engine2. Remember not to use an absolute URL (for example: http://www.111cn.net/nokia/n96/form), if
following functions, copy and paste the code of line (s), go to notepad, and save the file. And upload the file to the Web server in the root directory of the website.Here:Custom error pageDon't you hate it when people access your website through a bad link and are facing an error message, such as "license denied" or "no web page found "? Then, you can create custom error pages for busy error messages. For each type of error, it is expected that your visit will encounter
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.