Hi, Baidu, this article you don't accept, oh, Baidu can not understand, the title:
. htaccess some of the common configurations
Custom PHP Error log directory
It is useful to save the error log in PHP running to a specified directory, and checking the error log frequently can help us check the program problem, htaccess set as follows:
The code is as follows |
Copy Code |
1.# officially uploaded program off to display error tips to client browsers 2.# Php_flag display_startup_errors off 3.# Php_flag display_errors off 4.# Php_flag html_errors off 5.# to save the error log in the specified directory. 6.php_flag log_errors on 7.php_value Error_log/home/lao8_org/error.log
|
Web page gzip compression, improve user access speed
The speed of the Web page is based on the size of the Web page and network speeds, when the Internet can not improve the size of the page can only change, GIZP compression is such a function.
This can be absolutely, such as login Baidu Webmaster platform you will find that the page optimization suggestion tool There will be a hint of this optimization, in the. htaccess Add this paragraph:
The code is as follows |
Copy Code |
1. Addoutputfilterbytype DEFLATE text/html text/css text/plain text/xml application/x-httpd-php application/ X-javascript
|
NOTE: If you configure your server to support gzip compression by default please refer to article: apache%c5%e4%d6%c3/"target=" _blank ">apache Configure gzip compression page to optimize network speed
Use. htaccess to correct the wrong page code
Development program friends know that if a page is gb2312 encoded, b page is utf-8 encoded, if a page include reference b page will produce garbled, you can use. htaccess for Web page revision code:
The code is as follows |
Copy Code |
1.<filesmatch ". (HTM|HTML|CSS|JS) $ "> 2.AddDefaultCharset UTF-8
|
Custom 404 Error page
I think a normal blog/site should have its own error page, which helps us to increase the user experience, but also help guide customers to visit our website, increase the number of visits.
Create a 404 error page First, then add the following code to the. htaccess:
The code is as follows |
Copy Code |
1.ErrorDocument 404/404.php
|
Extrapolate, specify 403:errordocument 403/403.html
Home 301 Redirect
This absolutely must have, conducive to SEO oh, such as input lao8.org will automatically jump to Www.111cn.net, is in the. htaccess add the following code to implement:
The code is as follows |
Copy Code |
1.RewriteEngine on 2.RewriteCond%{http_host}!^lao8.org$ [NC] 3.RewriteRule ^ (. *) $ http://www.111cn.net/$1 [l,r=301]
|
Rewriteengine on means to open the URL rewrite, which should be placed in front of the htaccess to facilitate subsequent calls.
Pseudo-static method for dynamic Web pages
The code is as follows |
Copy Code |
1.RewriteRule ^id (d+). html/wenzhang.php?id=$1 |
This article from: www.lao8.org/blog