Public
snipts » htaccess
showing 1-20 of 43 snipts for htaccess
-
∞ htaccess redirect all traffic to homepage
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . http://domain.tld/index.php [L] </IfModule>
-
∞ mod_rewrite to fix blogger moving
RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/blog/images/(.*)$ [NC] RewriteCond %{REQUEST_URI} ^/blog/(.*)$ [NC] RewriteRule ^blog/(.*)$ http://blog.domain.com/$1 [R=301,L]
-
∞ Prevent .htaccess and .htpasswd file from being viewed by web clients
# # The following lines prevent .htaccess and .htpasswd files from being # viewed by Web clients. # <Files ~ "^\.ht"> Order allow,deny Deny from all </Files>
-
∞ Apache non-www .htaccess config
Options +FollowSymLinks RewriteEngine On RewriteBase / RewriteCond %{HTTP_HOST} !^apaair\.aero$ [NC] RewriteRule ^(.*)$ http://apaair.aero/$1 [R=301,L] # Important: It is needed to have mod_rewrite MODULE activated and have "AllowOverride Directive" set to ALL.
-
∞ better .htaccess noindex
Header set X-Robots-Tag "noindex, nofollow"
-
∞ Basic query string rewriting with mod_rewrite
<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$ - [S=40] RewriteRule ^([A-Za-z0-9\_]+)?/?$ /index.php?page=$1 [QSA,L] RewriteRule ^(events|news)/([0-9]+)/?$ /index.php?page=$1&id=$2 [L] RewriteRule ^(events|news)/([0-9]+)/([0-9]+)/([0-9]+)/?$ /index.php?page=$1&year=$2&month=$3&id=$4 [L] RewriteRule ^(events|news)/([0-9]+)/([0-9]+)/?$ /index.php?page=$1&year=$2&month=$3 [L] #RewriteRule ^([^/\.]+)/?$ /index.php?page=$1 [L] </IfModule>
-
∞ 301 redirect - non-www to www
RewriteEngine On RewriteCond %{HTTP_HOST} ^example.com RewriteRule (.*) http://www.example.com/$1 [R=301,L]
-
∞ Cache 2nd try
# Turn on Expires and set default expires to 3 days ExpiresActive On ExpiresDefault A259200 # Set up caching on media files for 1 month <FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$"> ExpiresDefault A2419200 Header append Cache-Control "public" </FilesMatch>
-
∞ Cache images
<IfModule mod_expires.c> ===> btn-send.png 1 HTTP/1.1 2 Date: Sat, 25 Feb 2006 20:59:28 GMT 4 Cache-Control max-age=2592000 5 Expires: Mon, 27 Mar 2006 20:59:28 GMT 6 Last-Modified: Thu, 16 Feb 2006 12:07:03 GMT 7 ETag: "b57d55" 8 Accept-Ranges: bytes 9 Content-Length: 608 11 Connection: Keep-Alive 12 Content-Type: image/png </IfModule>
-
∞ detect iphone
.htaccess #redirect mobile browsers RewriteCond %{HTTP_USER_AGENT} ^.*iPhone.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*BlackBerry.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] RewriteCond %{HTTP_USER_AGENT} ^.*Palm.*$ RewriteRule ^(.*)$ http://mobile.yourdomain.com [R=301] Javascript <script language=javascript> <!– if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) { location.replace("iphone-version.html"); } –> </script>
-
∞ Common .htaccess rules
# Google Apps redirect Redirect 301 /mail http://mail.google.com/a/domain.com # File execution order DirectoryIndex index.php index.html # Added to prevent directory browsing Options -Indexes # Redirect primary cPanel "domain.com" to a subfolder with same name: /domain.com/ RewriteEngine on RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC] RewriteCond %{REQUEST_URI} !^/domain.com/ RewriteRule ^/?(.*)$ /domain.com/$1 [L]
-
∞ Compress font files for use with @font-face
# Compress font files for use with @font-face Addtype font/opentype .otf Addtype font/truetype .ttf AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css font/opentype font/truetype # Comments: Both these declarations require their appropriate modules to be active: mod_mime and mod_deflate. And for best practice, the AddType declaration should be in the mime.conf file, and the AddOutputFilterByType declaration should be in the deflate.conf file. See your particular distribution's help files for enabling and configuring Apache modules.
-
∞ Uniserver mod rewrite enabled
Uniserver mod rewrite Put this at the end of the .htaccess file located in /udrive/www/ Options +FollowSymLinks RewriteEngine On
-
∞ php class to read username / password from a .htpasswd file
<?php //class to read username / password from a .htpasswd file class password{ var $p_lines = array(); var $p_pass = array(); var $en_pass = ""; var $username = ""; function password(){} function ReadPasswords($file) //^ { $this->p_lines = file($file); foreach ($this->p_lines as $line_num => $line) { @list($name, $pass) = split(":", $line); $this->p_pass[trim($name)] = trim($pass); } } function checkUserExists($user) { return isset($this->p_pass[$user])? true : false; } function lookupPass($user,$password) { if(isset($this->p_pass[$user])) { $salt = substr( $this->p_pass[$user] , 0 , 2 ); $enc_pw = crypt( $password, $salt ); if ($enc_pw == $this->p_pass[$user]) { return true; } else { return false; } } else return false; } } ?>
-
∞ Design max upload size
php_value upload_max_filesize 8M - www.bluecubemedia.co.uk
-
∞ html as php .htaccess
# let html files act as php files AddType application/x-httpd-php .php .htm .html
-
∞ base .htaccess (rewrite)
Options +FollowSymLinks RewriteEngine On
-
∞ pooper snooper
# prevent open directories from browsing Options All -Indexes
-
∞ force download .htaccess
# force download certain file types AddType application/octet-stream .doc .mov .avi .pdf .xls .mp4
-
∞ speed things up in .htaccess
# speed things up <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>



MySQL Stored Procedure Programming