Skip to content

Instantly share code, notes, and snippets.

//truncate text
function truncate_text($string, $lenght) {
if( strlen( $string ) >= $lenght ) {
$string = strip_tags($string);
$string = substr($string, 0, $lenght);
$string = rtrim($string, "!,.-");
$string = substr($string, 0, strrpos($string, ' '));
$string = $string."… ";
}
<IfModule mod_expires.c>
<FilesMatch \.(gif|png|jpg|jpeg|ogg|mp4|mkv|flv|swf|wmv|asf|asx|wma|wax|wmx|wm)$>
ExpiresDefault "access plus 1 year"
</FilesMatch>
ExpiresActive on
ExpiresByType image/jpeg "access plus 7 day"
ExpiresByType image/gif "access plus 7 day"
ExpiresByType image/png "access plus 7 day"
<FilesMatch \.(css|js)$>
ExpiresDefault "access plus 1 year"
AuthType Basic
AuthName "My Protected Area"
AuthUserFile /home/h58768/data/www/ogn.pub-portfolio.pp.ua/.htpasswd
Require valid-user
@psics
psics / header.php
Created April 24, 2017 11:07
Редирект с верхнего регистра на нижний
<?php
$url = mb_strtolower(urldecode($_SERVER['REQUEST_URI']), 'UTF-8') ;
if(urldecode($_SERVER['REQUEST_URI']) != $url) {
header('Location: http://'.$_SERVER['HTTP_HOST'].$url, true, 301) ;
}
?>
@psics
psics / .htaccess
Created April 24, 2017 11:05
htaccess редирект на без www и без /
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^\/$
RewriteCond %{HTTP_HOST} ^www\.(.*)$
RewriteRule ^(.*)$ http://%1/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !\?
RewriteCond %{REQUEST_URI} !\&
RewriteCond %{REQUEST_URI} !\=