1. Anti-hotlinking
Websites that steal your content and don't want to store images on their own are shameless. You can use the following configuration to place someone else to steal your image:
1 Rewritebase/
2 Rewritecond%{http_referer}!^$
3 Rewritecond%{http_referer}!^http://(www.) yoursite.com/.*$ [NC]
4 Rewriterule. (gif|jpg|swf|flv|png) $/feed/[r=302,l]
2. Prevent Directory browsing
Sometimes directory browsing is useful, but in most cases there is a security issue. To make your site more secure, you can disable this feature through the htaccess file:
1 Options all-indexes
3. SEO-friendly 301 Permanent redirect
This is a trick I used to use. Every time I change the site URL structure, I do 301 redirects:
1 Redirect 301 http://www.yoursite.com/article.html http://www.yoursite.com/archives/article
4. Display the personalized 404 error page
When a user accesses a page that does not exist, the Web server displays the "404 File Not Found" error. There are many CMS that allow you to set a custom error page, but the simplest way is to change the htaccess:
1 ErrorDocument 404/404.html
5. Set the default page for the directory
If you need to set different default pages for different directories, you can easily pass the. htaccess implementation:
1 DirectoryIndex about.html
6. Restricting site access based on Referer
webmasters typically do not restrict site access, but you should block them when you find that some sites are giving you garbage traffic:
1
2 Rewriteengine on Rewritecond%{http_referer} spamteam.com [Nc,or]
3 rewritecond%{http_referer} trollteam.com [NC,OR ]
4 rewriterule. *–[f]
5
7. Limit php Upload file size
This is useful on servers on a shared space, allowing my users to upload larger files. The first is to set the maximum upload file size, the second is to set the maximum POST request size, the third PHP script the longest execution time, and the last is the longest time the script resolves the upload file:
1 php_value upload_max_filesize 20M
2 php_value post_max_size 20M
3 php_value max_execution_time (
4 php_value max_input_time)
8. Compressing files
You can reduce network traffic by compressing files, as well as page load times:
1 Addoutputfilterbytype DEFLATE Text/plain
2 Addoutputfilterbytype DEFLATE text/html
3 Addoutputfilterbytype DEFLATE Text/xml
4 Addoutputfilterbytype DEFLATE Text/css
5 Addoutputfilterbytype DEFLATE Application/xml
6 Addoutputfilterbytype DEFLATE Application/xhtml+xml
7 Addoutputfilterbytype DEFLATE Application/rss+xml
8 Addoutputfilterbytype DEFLATE Application/javascript
9 Addoutputfilterbytype DEFLATE Application/x-javascript
9. cache files
Does this have to be explained?
1
2 Header set Cache-control "Max-age=2592000″
3
10. Add a trailing backslash
I'm not sure, but many articles, many people say adding a trailing backslash is beneficial for SEO:
1
2 Rewritecond%{request_uri}/+[^\. +$
3 Rewriterule ^ (. +[^/]) $%{request_uri}/[r=301,l]
4
Excerpt from Painsonline's column
http://www.bkjia.com/PHPjc/478306.html www.bkjia.com true http://www.bkjia.com/PHPjc/478306.html techarticle 1. Anti-hotlinking sites that have embezzled your content and are reluctant to store images on their own are shameless. You can use the following configuration to place someone else to steal your picture: 1rewritebase/2rew ...