Document directory
- 1. Time Zone settings
- 2. Search Engine-friendly 301 permanent redirection Method
- 3. Download blocking dialog box
- 4. the WWW prefix is omitted.
- 5. Personalized error page
- 6. compressed files
- 7. cache files
- 8. Disable caching for certain file types
- Security Questions
- 1. Put leeching through. htaccess
- 2. Anti-hacker
- 3. block access to your. htaccess File
- 4. Rename the htaccess File
- 5. Disable directory browsing
- 6. Change the default index page
- 7. Block some undesirable viewers by referencing information
- 8. Some requests are blocked by judging the browser header information
- 9. Prohibit script execution to enhance your Directory Security
1. Time Zone settings
Sometimes, when you use the date or mktime function in PHP, it will display some strange information due to different time zones. The following is one of the solutions to this problem. Is to set the time zone of your server. You canHereFind the list of all supported time zones.
- Setenv TZ Australia/Melbourne
2. Search Engine-friendly 301 permanent redirection Method
Why is this search engine friendly? Because many modern search engines now have the ability to update their existing records permanently based on check 301.
- Redirect 301 http://www.aqee.net/home http://www.aqee.net/
3. Download blocking dialog box
Generally, when you download a file, you will see a dialog box asking whether you want to keep the file or open it directly. If you don't want to see this, you can put the following code in your. htaccess file.
- Addtype application/octet-stream. PDF
- Addtype application/octet-stream. Zip
- Addtype application/octet-stream. mov
4. the WWW prefix is omitted.
One principle of Seo is to ensure that your website has only one URL. Therefore, you need to turn all the access via www to non-WWW, or reverse this.
- Rewriteengine on
- Rewritebase/
- Rewritecond % {http_host} ^ www.aqee.net [Nc]
- Rewriterule ^ (. *) $ http://aqee.net/#1 [L, r = 301]
5. Personalized error page
Customize custom error pages for each error code.
- Errordocument 401/error/401.php
- Errordocument 403/error/403.php
- Errordocument 404/error/404.php
- Errordocument 500/error/500.php
6. compressed files
By compressing your file volume, you can optimize the Website access speed.
- # Compressing text, HTML, JavaScript, CSS, and XML:
- Addoutputfilterbytype deflate text/plain
- Addoutputfilterbytype deflate text/html
- Addoutputfilterbytype deflate text/XML
- Addoutputfilterbytype deflate text/CSS
- Addoutputfilterbytype deflate application/XML
- Addoutputfilterbytype deflate application/XHTML + XML
- Addoutputfilterbytype deflate application/RSS + XML
- Addoutputfilterbytype deflate application/JavaScript
- Addoutputfilterbytype deflate application/X-Javascript
7. cache files
Caching files is another good way to speed up your website access.
- <Filesmatch ". (FLV | GIF | JPG | JPEG | PNG | ICO | SWF | JS | CSS | PDF) $">
- Header set cache-control "Max-age = 2592000 ″
- </Filesmatch>
8. Disable caching for certain file types
On the other hand, you can also disable caching for certain file types.
- # Explicitly prohibit the use of cache for scripts and other dynamic files
- <Filesmatch ". (PL | PHP | CGI | SPL | scgi | fcgi) $">
- Header unset cache-control
- </Filesmatch>
Security Questions
The following htaccess code can improve the security level of your Web server. Image link theft protection is very useful, it can prevent others from using the image resources on your server.
1. Put leeching through. htaccess
Hate the image resources on your web server that steal links and consume your bandwidth? You can try this to prevent this from happening.
- Rewritebase/
- Rewritecond % {http_referer }! ^ $
- Rewritecond % {http_referer }! ^ Http: // (www .)? Aqee.net/.*$ [Nc]
- Rewriterule. (GIF | JPG | SWF | FLV | PNG) $/feed/[R = 302, l]
2. Anti-hacker
If you want to improve the security level of your website, you can remove the following lines of code to prevent hacker attack techniques that match common malicious URLs.
- Rewriteengine on
- # Proc/self/environ? No!
- Rewritecond % {QUERY_STRING} proc/self/environ [or]
- # Prevent the script from attempting to modify the mosconfig value through URL
- Rewritecond % {QUERY_STRING} mosconfig _ [A-Za-Z _] {} (=|\% 3d) [or]
- # Block base64_encode junk information transmitted by a script through a URL
- Rewritecond % {QUERY_STRING} base64_encode. * (. *) [or]
- # Block scripts with the <SCRIPT> flag in the URL
- Rewritecond % {QUERY_STRING} (<| % 3C). * script. * (>|% 3e) [NC, or]
- # Block scripts that attempt to set the globals variable of PHP through URL
- Rewritecond % {QUERY_STRING} globals (= | [| \ % [0-9a-z] {0, 2}) [or]
- # Block scripts that attempt to set the PHP _ Request variable through URL
- Rewritecond % {QUERY_STRING} _ Request (= | [|\% [0-9a-z] {0, 2 })
- # Redirect all blocked requests to the 403 Forbidden prompt page!
- Rewriterule ^ (. *) $ index. php [F, L]
3. block access to your. htaccess File
The following code prevents others from accessing your. htaccess file. You can also block multiple file types.
- # Protect Your htaccess files
- <Files. htaccess>
- Order allow, deny
- Deny from all
- </Files>
- # Block viewing of specified files
- <Files secretfile.jpg>
- Order allow, deny
- Deny from all
- </Files>
- # Multiple File Types
- <Filesmatch ". (htaccess | htpasswd | ini | PHPs | FLA | PSD | log | SH) $">
- Order allow, deny
- Deny from all
- </Filesmatch>
4. Rename the htaccess File
You can rename the htaccess file to protect it.
- Accessfilename htacc. Ess
5. Disable directory browsing
Disable the server from displaying the directory structure externally, and vice versa.
- # Prohibit directory browsing
- Options all-Indexes
- # Open Directory Browsing
- Options all + Indexes
6. Change the default index page
You can change the default index.html, index. php, or index.htm to another page.
- Directoryindex business.html
7. Block some undesirable viewers by referencing information
- # Blocking users from a website
- <Ifmodule mod_rewrite.c>
- Rewriteengine on
- Rewritecond % {http_referer} scumbag.com [NC, or]
- Rewritecond % {http_referer} wormhole.com [NC, or]
- Rewriterule. *-[F]
- </Ifmodule>
8. Some requests are blocked by judging the browser header information
This method can save your bandwidth traffic by preventing some robots or spider crawlers from crawling your website.
- # Blocking users from certain websites
- <Ifmodule mod_rewrite.c>
- Setenvifnocase ^ User-Agent $. * (craftbot | download | extract | stripper | sucker | ninja | clshttp | webspider
| Leacher | collector | grabber | webpictures) http_safe_badbot
- Setenvifnocase ^ User-Agent $. * (libwww-perl | aesop_com_spiderman) http_safe_badbot
- Deny from Env = http_safe_badbot
- </Ifmodule>
9. Prohibit script execution to enhance your Directory Security
- # Prohibit script execution permissions in some Directories
- Addhandler CGI-script. php. pl. py. jsp. asp. htm. shtml. Sh. cgi
- Options-execcgi
Http://www.aqee.net/htaccess-usage/