. htaccess set the order of the site's default home page
Add the following line to the. htaccess file:
The code is as follows |
Copy Code |
DirectoryIndex index.html index.htm index.php |
Htaccess set 404 Error page Method
The way to set the 404 error page for Apache server is simple: simply add the following code to the. htaccess file.
The code is as follows |
Copy Code |
ErrorDocument 404/notfound.html |
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 seo/seo.html "target=" _blank > Search engine.
2. Remember not to use an absolute URL (for example: http://www.111cn.net/nokia/n96/form), if the status code returned using an absolute URL is "302" + "200" (tested)
The right thing to do is to add the following code to the. htaccess:
The code is as follows |
Copy Code |
1 ErrorDocument 404/404.htm Instead of:
1 errordocument 404 http://www.xxx.com/404.htm
|
The former returns a 404 status Code,
And the latter returns a 200 status code. If the content of a 404 page is less than 512b,ie would think that the 404 page is not friendly enough, the 404 error page will not be successfully returned under IE.
htaccess Add the trailing slash of the URL
Add the following code in the htaccess file:
The code is as follows |
Copy Code |
Ifmodule mod_rewrite.c Rewritecond%{request_uri}/+[^.] +$ Rewriterule ^ (. +[^/]) $%{request_uri}/[r=301,l] /ifmodule |
301 redirect. Htaccess will jump to the WWW url without www
The htaccess is written as follows, replacing pcjs.cn with your URL:
The code is as follows |
Copy Code |
Options +followsymlinks Rewriteengine on Rewritecond%{http_host} ^111cn.net [NC] Rewriterule ^ (. *) $ http://www.111cn.net/$1 [r=301,l] |
use. htaccess anti-theft chain
The premise of the Mod_rewrite module in Apache is activated, since to eliminate the hotlinking of the MP3 file is also the way to the picture hotlinking settings to do, the following is my site in the root directory of the. htaccess file configuration, for the people of Freemasonry for reference:
Code in the. htaccess file:
The code is as follows |
Copy Code |
Rewriteengine on Rewritecond%{http_referer}!^http://(www.)? 111cn.net/.*$ [NC] Rewriterule. (txt|doc|jpg|gif|mp3|zip|rar|png) $ http://www.111cn.net [r=301,l] |
Functions: not only to screen/prohibit hotlinking access to the site, but also hotlinking request to its own website, let the reader know who is the real original author.
Code Description:
Rewritecond condition: The meaning is all mp3, rar, picture, etc., visit if Referer is not this website pcjs.cn or www.pcjs.cn,
Rewriterule rules: Automatically to the site homepage
The commented out section is used for testing rewrite engine: useful for debugging mod_rewrite.
Other anti-theft chain of some settings, you can refer to:
code is as follows |
copy code |
#开启mod_ Rewrite engine Rewriteengine on #设置合法请求源 Rewritecond%{http_referer}!^$ [NC] Rewritecond%{http_referer}! Www.111cn.net [NC] Rewritecond%{http_referer}!google.com [NC] Rewritecond%{http_referer}!baidu.com [NC] Rewritecond%{http_referer}!yahoo.com [NC] Rewritecond%{http_referer}!msn.com [NC] #指向警告页面图片 Rewriterule .*. (Gif|jpg|png|mp3) $ warning.png [L,NC] |