Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Универсальное решение проблемы постоянных редиректов на домен без www при помощи mod_rewrite.
- # Просто и полезно. Работает на любом домене без необходимости править для каждого сайта.
- # В корень бросаем файл .htaccess со следующим содержимым:
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteBase /
- # В переменную окружения %{ENV:PROTOCOL} помещаем протокол
- RewriteRule ^(.*)$ - [E=PROTOCOL:http]
- RewriteCond %{HTTPS} ^on$ [NC]
- RewriteRule ^(.*)$ - [E=PROTOCOL:https]
- # Если нужно убираем www
- RewriteCond %{SERVER_PORT} ^80$
- RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
- RewriteRule ^(.*)$ %{ENV:PROTOCOL}://%1%{REQUEST_URI} [R=301,L]
- RewriteCond %{HTTP_HOST} ^www\.(.*) [NC]
- RewriteRule ^(.*)$ %{ENV:PROTOCOL}://%1:%{SERVER_PORT}%{REQUEST_URI} [R=301,L]
- </IfModule>
- # www.example.net is a valid address, but it redirects all traffic to example.net.
- RewriteEngine On
- RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
- RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
- # temp redirect wordpress content feeds to feedburner
- <IfModule mod_rewrite.c>
- RewriteEngine on
- RewriteCond %{HTTP_USER_AGENT} !FeedBurner [NC]
- RewriteCond %{HTTP_USER_AGENT} !FeedValidator [NC]
- RewriteRule ^feed/?([_0-9a-z-]+)?/?$ http://feeds.feedburner.com/yourblog [R=302,NC,L]
- </IfModule>
- # disable hotlinking
- Options +FollowSymlinks
- RewriteEngine On
- RewriteCond %{HTTP_REFERER} !^$
- RewriteCond %{HTTP_REFERER} !^http://(www.)?domainname.com/ [nc]
- RewriteRule .*.(gif|jpg|png)$ http://domainname.com/img/stop_stealing_bandwidth.gif[nc]
- # Сжатие с mod_deflate
- # Наряду с Gzip архивированием файлов, вы можете использовать mod_deflate (что предположительно быстрее).
- # Поместите указанный код в начало вашего .htaccess файла
- # (вы также можете добавить картинки .jpg, .gif, .png, .tiff, .ico).
- <ifmodule mod_deflate.c="">
- <filesmatch .(js|css)$="">
- SetOutputFilter DEFLATE
- </filesmatch>
- </ifmodule>
- ####### PHP DEBUGGING RULES #######
- # supress display of php errors, Below three lines will disable the PHP error reporting to user
- php_flag display_startup_errors off
- php_flag display_errors off
- php_flag html_errors off
- # enable verbose PHP error logging to a file, Below three lines will log the all PHP error, warning and notices in log files at the path specified.
- php_flag log_errors on
- php_value error_reporting 2047
- php_value error_log /home/domain.com/php.error.log
- ####### END PHP DEBUGGING RULES #######
- #Увеличиваем максимальный размер загружаемого файла
- php_value upload_max_filesize 100M
- #Увеличиваем максимальный размер файла передаваемого пост-запросом
- php_value post_max_size 100M
- #Увеличиваем время выполнения скрипта
- php_value max_execution_time 700
- # Redirect HTTP tO HTTPS
- RewriteEngine On
- RewriteCond %{HTTPS} off
- RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
- # Сжатие текстовых файлов
- 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
- <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 handler ^cgi-script$
- mod_gzip_item_include mime ^text\.*
- mod_gzip_item_include mime ^application/x-javascript.*
- mod_gzip_item_exclude mime ^image\.*
- mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
- </IfModule>
- # Обход диалога загрузки
- AddType application/octet-stream .pdf
- AddType application/octet-stream .zip
- AddType application/octet-stream .mp3
- # Кэширование файлов
- <FilesMatch ".(flv|gif|jpg|jpeg|png|ico|swf|js|css|pdf)$">
- Header set Cache-Control "max-age=2592000"
- </FilesMatch>
- # удаление слэша на конце URL
- RewriteEngine On
- RewriteBase /
- RewriteCond %{HTTP_HOST} (.*)
- RewriteCond %{REQUEST_URI} /$ [NC]
- RewriteRule ^(.*)(/)$ $1 [L,R=301]
- # добавление слэша в конец URL
- RewriteEngine On
- RewriteBase /
- RewriteCond %{REQUEST_FILENAME} !-f
- RewriteCond %{REQUEST_URI} !(.*)/$
- RewriteRule ^(.*[^/])$ $1/ [L,R=301]
- # CORSifying
- <IfModule mod_headers.c>
- Header add Access-Control-Allow-Origin "*"
- Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
- Header set Access-Control-Allow-Headers "Content-Type, Authorization"
- </IfModule>
Advertisement
Add Comment
Please, Sign In to add comment