apache_conf 理想.htaccess http://habrahabr.ru/post/154643/

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache_conf 理想.htaccess http://habrahabr.ru/post/154643/相关的知识,希望对你有一定的参考价值。

# Этот .htaccess поможет сделать ваш сайт быстрей.
# Пользуйтесь на здоровье себе и вашему сайту.
# Автор: Алекснадр Белов aka alex Roosso
# Сайт: http://www.black-web.ru
# ICQ: 3405729
 
Options All -ExecCGI -Indexes -Includes +FollowSymLinks
#Options -MultiViews
 
# REWRITE ___________________
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /
	RewriteCond %{HTTP_HOST} ^iblog
	RewriteRule (.*) http://www.iblog.su/$1 [R=301,L]
	RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
	RewriteRule ^index\.php$ http://www.iblog.su/ [R=301,L]
</IfModule>
 
# REDIRICT __________________
# Redirect 301 /index.html /index.php
<IfModule mod_rewrite.c>
	# RewriteRule ^news/([^/\.]+)/?$ news.php?news=$1 [L]
	# RewriteRule ^(.*\.((js)|(css)))$ plugin/GzipFile.php?file=$1
	# RewriteRule \.css$ plugin/GzipFile.php?file=$1
	# RewriteRule \.js$ plugin/GzipFile.php?file=$1
</IfModule>
# RedirectMatch 301 /blog(.*) http://www.iblog.su/$1
 
 
# SECURE ____________________
<IfModule mod_ssl.c>
	# SSLOptions +StrictRequire
	# SSLRequireSSL
	# SSLRequire %{HTTP_HOST} eq "iblog.su"
</IfModule>
<IfModule mod_rewrite.c>
	# RewriteCond %{HTTPS} !on
	# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
	# RewriteCond %{SERVER_PORT} !^443
	# RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
 
	# Блокировать любой запрос, пытающийся испортить base64_encode через URL
	RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
	# Блокировать любой запрос, содержащий тег <script> в URL
	RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
	# Блокировать любой запрос, пытающийся установить значение глобальных переменных PHP через URL
	RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
	# Блокировать любой запрос, пытающийся изменить _REQUEST переменную через URL
	RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
	# Перенаправлять заблокированные запросы
	RewriteRule .* index.php [F]
 
	# и запрошенный путь не соответствует пути к физическому файлу
	RewriteCond %{REQUEST_FILENAME} !-f
	# и запрошенный путь не соответствует пути к физической папке
	RewriteCond %{REQUEST_FILENAME} !-d
	# то перенаправить запрос на скрипт index.php
	RewriteRule .* index.php [L]
</IfModule>
 
 
# HOTLINKING ________________
<IfModule mod_rewrite.c>
	# RewriteCond %{HTTP_REFERER} !^$
	# RewriteCond %{HTTP_REFERER} !^http://([ -a-z0-9]  \.)?ibog\.su [NC]
	# RewriteRule \.(gif|jpe?g|png)$ - [F,NC,L]
</IfModule>
 
# HANDLER ___________________
AddHandler application/x-httpd-php .html
AddHandler cgi-script .pl .py .jsp .asp .htm .shtml .sh .cgi
AddType application/x-javascript .js
AddType application/json json
AddType text/css .css
AddType text/xml .xml
AddType text/x-component .htc
# Audio
AddType audio/ogg oga ogg
AddType audio/mp4 m4a f4a f4b
# Video
AddType video/ogg ogv
AddType video/mp4 mp4 m4v f4v f4p
AddType video/webm webm
AddType video/x-flv flv
# SVG
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# Webfonts
AddType application/vnd.ms-fontobject eot
AddType application/x-font-ttf ttf ttc
AddType font/opentype otf
AddType application/x-font-woff woff
# Assorted types
AddType image/x-icon ico
AddType image/webp webp
AddType text/cache-manifest appcache manifest
AddType text/x-component htc
AddType application/xml rss atom xml rdf
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType application/octet-stream safariextz
AddType application/x-web-app-manifest+json webapp
AddType text/x-vcard vcf
AddType application/x-shockwave-flash swf
AddType text/vtt vtt
AddType application/octet-stream .doc .mov .avi .pdf .xls .rar .zip .mp3 .wmv .ppt .tar .gz .docx .xlsx
# ForceType application/x-httpd-php
 
# INDEX FILE ________________
DirectoryIndex index.php
 
# GZIP ______________________
<IfModule mod_gzip.c>
	mod_gzip_on         Yes
	mod_gzip_dechunk    Yes
	mod_gzip_item_include file		\.(html?|txt|css|js|php|pl)$
	mod_gzip_item_include mime		^text\.*
	mod_gzip_item_include mime		^application/x-javascript.*
	mod_gzip_item_include mime		^application/x-font-woff.*
	mod_gzip_item_exclude mime		^image\.*
	mod_gzip_item_exclude rspheader	^Content-Encoding:.*gzip.*
</IfModule>
<ifModule mod_deflate.c>
	AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/css text/javascript application/javascript application/x-javascript application/x-font-woff image/jpg image/jpeg
</ifModule>
 
# PHP _______________________
php_value	upload_max_filesize	32M
php_value	post_max_size		10M
php_value	default_charset utf-8
# php_value	max_execution_time 200
# php_value	max_input_time 200
# php_flag register_globals Off
# php_value session.name sid
# php_flag magic_quotes_gpc Off
# php_flag expose_php Off
# php_value error_reporting -1
# php_flag log_errors On
# php_flag display_errors Off
# php_flag display_startup_errors Off
# php_flag html_errors Off
# php_flag ignore_repeated_errors Off
# php_flag ignore_repeated_source Off
# php_value log_errors_max_len 1024
# php_value error_prepend_string " "
# php_value error_append_string " "
<IfModule php5_module>
	# php_value session.cookie_httponly true
</IfModule>
 
# OTHER SETTINGS ____________
<IfModule mod_setenvif.c>
	SetEnv TZ Europe/Moscow
</IfModule>
ServerSignature Off
# AddDefaultCharset UTF-8
# AddCharset utf-8 .atom .css .js .json .rss .vtt .xml
 
# CACHE AND Headers _________
<ifModule mod_headers.c>
	<FilesMatch "\.(html|htm)$">
		Header set Cache-Control "max-age=43200"
	</FilesMatch>
	<FilesMatch "\.(js|css|txt)$">
		Header set Cache-Control "max-age=604800"
	</FilesMatch>
	<FilesMatch "\.(flv|swf|ico|gif|jpg|jpeg|png|jpe?g)$">
		Header set Cache-Control "max-age=2592000"
	</FilesMatch>
	<FilesMatch "\.(pl|php|cgi|spl|scgi|fcgi)$">
		Header unset Cache-Control
	</FilesMatch>
	<FilesMatch "\.(ttf|ttc|otf|eot|woff|font.css)$">
		Header set Access-Control-Allow-Origin "*"
	</FilesMatch>
	<FilesMatch "\.(js|css|gif|png|jpe?g|pdf|xml|oga|ogg|m4a|ogv|mp4|m4v|webm|svg|svgz|eot|ttf|otf|woff|ico|webp|appcache|manifest|htc|crx|oex|xpi|safariextz|vcf)$" >
		Header unset X-UA-Compatible
	</FilesMatch>
</IfModule>
<ifModule mod_expires.c>
	ExpiresActive On
	ExpiresDefault "access plus 5 seconds"
	ExpiresByType image/x-icon "access plus 2592000 seconds"
	ExpiresByType image/jpeg "access plus 2592000 seconds"
	ExpiresByType image/png "access plus 2592000 seconds"
	ExpiresByType image/gif "access plus 2592000 seconds"
	ExpiresByType video/ogg "access plus 1 month"
	ExpiresByType audio/ogg "access plus 1 month"
	ExpiresByType video/mp4 "access plus 1 month"
	ExpiresByType video/webm "access plus 1 month"
	ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
	ExpiresByType text/css "access plus 604800 seconds"
	ExpiresByType text/javascript "access plus 604800 seconds"
	ExpiresByType application/javascript "access plus 604800 seconds"
	ExpiresByType application/x-javascript "access plus 604800 seconds"
	ExpiresByType text/html "access plus 43200 seconds"
	ExpiresByType application/xhtml+xml "access plus 600 seconds"
	ExpiresByType text/xml "access plus 600 seconds"
	ExpiresByType application/xml "access plus 600 seconds"
	ExpiresByType application/json "access plus 600 seconds"
	ExpiresByType application/rss+xml "access plus 1 hour"
	ExpiresByType application/atom+xml "access plus 1 hour"
	ExpiresByType text/x-component "access plus 1 week"
	ExpiresByType application/x-font-ttf "access plus 1 month"
	ExpiresByType font/opentype "access plus 1 month"
	ExpiresByType application/x-font-woff "access plus 1 month"
	ExpiresByType image/svg+xml "access plus 1 month"
	ExpiresByType application/vnd.ms-fontobject "access plus 1 month"
</ifModule>
 
 
# Bad Rquest
ErrorDocument 400 /index.php?page=e400
 
# Authorization Required
ErrorDocument 401 /index.php?page=e401
 
# Forbidden
ErrorDocument 403 /index.php?page=e403
 
# Not found
ErrorDocument 404 /index.php?page=e404
 
# Method Not Allowed
ErrorDocument 405 /index.php?page=e405
 
# Request Timed Out
ErrorDocument 408 /index.php?page=e408
 
# Request URI Too Long
ErrorDocument 414 /index.php?page=notfound
 
# Internal Server Erro
ErrorDocument 500 /index.php?page=notfound
 
# Not Implemented
ErrorDocument 501 /index.php?page=notfound
 
# Bad Gateway 
ErrorDocument 502 /index.php?page=notfound
 
# Service Unavailable 
ErrorDocument 503 /index.php?page=notfound
 
# Gateway Timeout
ErrorDocument 504 /index.php?page=notfound

以上是关于apache_conf 理想.htaccess http://habrahabr.ru/post/154643/的主要内容,如果未能解决你的问题,请参考以下文章

apache_conf 通过.htaccess(主.htaccess)保护wordpress网站

apache_conf [linux:.htaccess] apache的htaccess说明。 #linux #apache

apache_conf Seguridad .htaccess

apache_conf htaccess的

apache_conf 重定向htaccess

apache_conf [htaccess的]