Sign up to create your own snipts, or login.

Public snipts » htaccess The latest public htaccess snipts.

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>
    

    copy | embed

    0 comments - tagged in  posted by rendrag on Feb 06, 2010 at 1:49 p.m. EST
  • 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]
    

    copy | embed

    0 comments - tagged in  posted by malkir on Feb 04, 2010 at 1:23 a.m. EST
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by yvoictra on Jan 16, 2010 at 6:02 p.m. EST
  • 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.
    

    copy | embed

    0 comments - tagged in  posted by yvoictra on Jan 16, 2010 at 9:05 a.m. EST
  • better .htaccess noindex
    Header set X-Robots-Tag "noindex, nofollow"
    

    copy | embed

    0 comments - tagged in  posted by alifity on Dec 18, 2009 at 1:37 a.m. EST
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by trey on Dec 02, 2009 at 4:54 p.m. EST
  • 301 redirect - non-www to www
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]
    

    copy | embed

    0 comments - tagged in  posted by carsonblack on Nov 18, 2009 at 4:18 a.m. EST
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by frankjonen on Nov 10, 2009 at 4:39 p.m. EST
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by frankjonen on Nov 10, 2009 at 4:09 p.m. EST
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by curosio on Nov 02, 2009 at 3:55 a.m. EST
  • 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]
    

    copy | embed

    0 comments - tagged in  posted by fevangelou on Oct 20, 2009 at 2:29 p.m. EDT
  • 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.
    

    copy | embed

    0 comments - tagged in  posted by fevangelou on Oct 20, 2009 at 10:50 a.m. EDT
  • Uniserver mod rewrite enabled
    Uniserver mod rewrite
    
    Put this at the end of the .htaccess file located in /udrive/www/
    
    Options +FollowSymLinks
    RewriteEngine On
    

    copy | embed

    0 comments - tagged in  posted by ZilverDragOn on Oct 12, 2009 at 7:48 a.m. EDT
  • 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;
       }
    }
    ?>
    

    copy | embed

    0 comments - tagged in  posted by matt_dunckley on Oct 01, 2009 at 11:14 a.m. EDT
  • Design max upload size
    php_value upload_max_filesize 8M
    
     - www.bluecubemedia.co.uk
    

    copy | embed

    0 comments - tagged in  posted by bluecube on Aug 26, 2009 at 6:51 a.m. EDT
  • html as php .htaccess
    # let html files act as php files
    AddType application/x-httpd-php .php .htm .html
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 19, 2009 at 7:44 a.m. EDT
  • base .htaccess (rewrite)
    Options +FollowSymLinks
    
    RewriteEngine On
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 19, 2009 at 7:42 a.m. EDT
  • pooper snooper
    # prevent open directories from browsing
    Options All -Indexes
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 19, 2009 at 7:42 a.m. EDT
  • force download .htaccess
    # force download certain file types
    AddType application/octet-stream .doc .mov .avi .pdf .xls .mp4
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 19, 2009 at 7:41 a.m. EDT
  • 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>
    

    copy | embed

    0 comments - tagged in  posted by d13t on Aug 19, 2009 at 7:41 a.m. EDT
Sign up to create your own snipts, or login.