Htaccess - Informasi, penggunaan dan triknya

Discussion in 'Site & Server Administration' started by Fahmi, Jan 25, 2013.

  1. Fahmi

    Fahmi Newbie

    Joined:
    Dec 5, 2012
    Messages:
    1,719
    Likes Received:
    159
    Trophy Points:
    63
    Google+:
    Htaccess http://en.wikipedia.org/wiki/Htaccess
    Htaccess merupakan singkatan dari hypertext access , htaccess adalah file konfigurasi yang didukung oleh beberapa web server. Yang memungkinkan untuk men-desentrelisasi konfigurasi webserver.

    beberapa list penting konfigurasi dan fiturnya sebagai berikut :
    1. Authorisasi dan Otentikasi , bisa digunakan untuk keamanan per Direktori
    2. Rewrite Url's , mampu menulis ulang url yang panjang menjadi pendek sehingga baik untuk SEO
    3. Customisasi error respon , menyesuaikan setting 404 halaman dan untuk menunjukkan ke mesin pencari bahwa halaman telah pindah.
    4. Cache kontrol , memungkinkan server untuk mengontrol caching oleh browser web dan proxy untuk mengurangi bandwith penggunaan, Server beban, dan dirasakan lag

    bagaimana dengan cara mengoptimalisasinya ?
    berikut saya menemukan cara-cara untuk mengoptimalisasinya ,
    1. https://github.com/h5bp/html5-boilerplate , nah didalamnya terdapat file htaccess yg cukup mantap buat digunakan, defaultnya sudah cukup bagus.
    2. atau bisa juga gunakan yang ini https://github.com/sergeychernyshev/.htaccess , silahkan dipelajari saja dulu.

    semoga bermanfaat.
     
  2. Dan

    Dan Forum Bot

    Joined:
    Dec 4, 2012
    Messages:
    1,316
    Likes Received:
    257
    Trophy Points:
    83
    Google+:
    Terimakasih atas tips dan

    Terimakasih atas tips dan triknya *smile* bermanfaat sekali. Berikut adalah isi dari file htaccess milik sergeychernyshev
    Code:
    # This .htaccess file is used to speed up this website
    # See https://github.com/sergeychernyshev/.htaccess
    
    
    # ----------------------------------------------------------------------
    # Proper MIME type for all files
    #
    # Copied from the HTML5 boilerplate project's .htaccess file
    # https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess
    # ----------------------------------------------------------------------
    
    # JavaScript
    # Normalize to standard type (it's sniffed in IE anyways)
    # tools.ietf.org/html/rfc4329#section-7.2
    AddType	application/javascript js jsonp
    AddType	application/json json
    
    # 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
    # Required for svg webfonts on iPad
    # twitter.com/FontSquirrel/status/14855840545
    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
    
    # --------------------------------------------------------------------------------------
    # Compression: http://code.google.com/speed/page-speed/docs/payload.html#GzipCompression
    # --------------------------------------------------------------------------------------
    <IfModule mod_deflate.c>
    AddOutputFilter DEFLATE application/atom+xml
    AddOutputFilter DEFLATE application/json
    AddOutputFilter DEFLATE application/xhtml+xml
    AddOutputFilter DEFLATE application/xml
    AddOutputFilter DEFLATE text/css
    AddOutputFilter DEFLATE text/html
    AddOutputFilter DEFLATE text/plain
    AddOutputFilter DEFLATE text/x-component
    AddOutputFilter DEFLATE text/xml
    
    # The following MIME types are in the process of registration
    AddOutputFilter DEFLATE application/xslt+xml
    AddOutputFilter DEFLATE image/svg+xml
    
    # The following MIME types are NOT registered
    AddOutputFilter DEFLATE application/mathml+xml
    AddOutputFilter DEFLATE application/rss+xml
    
    # JavaScript has various MIME types
    AddOutputFilter DEFLATE application/javascript
    AddOutputFilter DEFLATE application/x-javascript
    AddOutputFilter DEFLATE text/ecmascript
    AddOutputFilter DEFLATE text/javascript
    
    # .ico files and other compressible images
    AddOutputFilter DEFLATE image/vnd.microsoft.icon
    AddOutputFilter DEFLATE image/x-icon
    AddOutputFilter DEFLATE image/bmp
    AddOutputFilter DEFLATE image/tiff
    AddOutputFilter DEFLATE application/pdf
    
    # compressible fonts (.woff is already compressed)
    AddOutputFilter DEFLATE font/opentype
    AddOutputFilter DEFLATE application/x-font-ttf
    AddOutputFilter DEFLATE application/vnd.ms-fontobject
    </IfModule>
    
    # ----------------------------------------------------------------------
    # Enabling filename rewriting (file.XXX.ext) if URL rewriting is enabled
    # Otherwise URLs will use query strings (file.ext?v=XXX)
    #
    # More proxies cache assets if there is no query string
    # ----------------------------------------------------------------------
    <IfModule mod_rewrite.c>
    RewriteEngine On
    
    # Setting up an environment variable so your code can detect if mod_rewrite rules are executable
    # in this folder and you can use file.123.jpg or you need to fall back to file.jpg?123
    RewriteRule . - [E=URLVERSIONREWRITE]
    
    # Rewrites a version in file.123.jpg as well as timestamped version file.123_m_12345123512354.jpg
    # to original file.jpg so you can use it instead of file.jpg?123 which isn't cached in some proxies.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)\.(\d+)(_m_\d+)?\.([^\.]+)$ . [L,QSA]
    
    # Rewrites a version in file.ac123fe.jpg to original file.jpg
    # so you can use it instead of file.jpg?123 which isn't cached in some proxies.
    # Used for hash-based URLs where having a timestamp is not necessary.
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)\.([a-z\d]+)\.([^\.]+)$ . [L,QSA]
    </IfModule>
    
    # -------------------------------------------------------------------------------------------------
    # Browser Caching: http://code.google.com/speed/page-speed/docs/caching.html#LeverageBrowserCaching
    #
    # Google recommends specifying the following for all cacheable resources:
    #
    # 1. Expires or Cache-Control max-age
    #
    # Set Expires to a minimum of one month, and preferably up to one year, in the future. (We
    # prefer Expires over Cache-Control: max-age because it is is more widely supported.) Do not
    # set it to more than one year in the future, as that violates the RFC guidelines.
    #
    # 2. Last-Modified or ETag
    #
    # Set the Last-Modified date to the last time the resource was changed. If the Last-Modified
    # date is sufficiently far enough in the past, chances are the browser won't refetch it.
    #
    # Per Google: "it is redundant to specify both Expires and Cache-Control: max-age, or to specify
    # both Last-Modified and ETag."
    # --------------------------------------------------------------------------------------------------
    <IfModule mod_expires.c>
    ExpiresActive On
    
    ExpiresByType application/json "access plus 1 year"
    ExpiresByType application/pdf "access plus 1 year"
    ExpiresByType application/x-shockwave-flash "access plus 1 year"
    ExpiresByType image/bmp "access plus 1 year"
    ExpiresByType image/gif "access plus 1 year"
    ExpiresByType image/jpeg "access plus 1 year"
    ExpiresByType image/png "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    ExpiresByType image/tiff "access plus 1 year"
    ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
       ExpiresByType image/x-icon "access plus 1 year"
    ExpiresByType text/css "access plus 1 year"
    ExpiresByType video/x-flv "access plus 1 year"
    ExpiresByType application/vnd.bw-fontobject "access plus 1 year"
    ExpiresByType application/x-font-ttf "access plus 1 year"
    ExpiresByType application/font-woff "access plus 1 year"
    ExpiresByType font/opentype "access plus 1 year"
    ExpiresByType image/webp "access plus 1 year"
    
    # The following MIME types are in the process of registration
    ExpiresByType application/xslt+xml "access plus 1 year"
    ExpiresByType image/svg+xml "access plus 1 year"
    
    # The following MIME types are NOT registered
    ExpiresByType application/mathml+xml "access plus 1 year"
    ExpiresByType application/rss+xml "access plus 1 year"
    
    # JavaScript has various MIME types
    ExpiresByType application/x-javascript "access plus 1 year"
    ExpiresByType application/javascript "access plus 1 year"
    ExpiresByType text/ecmascript "access plus 1 year"
    ExpiresByType text/javascript "access plus 1 year"
    </IfModule>
    
    # TODO: Set Last-Modified per Google's recommendation to complete browser caching
    
    # -------------------------------------------------------------------------
    # Disabling ETags as they are most likely misconfigured and
    # do not add functionalit beyond Last-Modified
    # -------------------------------------------------------------------------
    <IfModule mod_headers.c>
    # Try removing etag headers (if it's coming from proxy for example)
    Header unset ETag
    </IfModule>
    
    # Remove ETags
    FileETag None
    
     
  3. ukmdigital

    ukmdigital New Member

    Joined:
    Feb 6, 2013
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    6
    Ijin bookmark mas nice

    Ijin bookmark mas :D nice sharing.
     
  4. orlandolabz

    orlandolabz New Member

    Joined:
    May 21, 2013
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    1
    itu htaccess bisa dipasangkan

    itu htaccess bisa dipasangkan kesemua tipe website ya mas ?
     
  5. ncang

    ncang Super Level

    Joined:
    Feb 7, 2013
    Messages:
    4,653
    Likes Received:
    761
    Trophy Points:
    113
    Google+:
    wah ternyata banyak juga

    *belajar* wah ternyata banyak juga kegunaan dari .htaccess kebiasaan pake blogger jadi tidak tahu yang begian *stres*
     
  6. AhmadWafa

    AhmadWafa Member

    Joined:
    Oct 2, 2013
    Messages:
    870
    Likes Received:
    16
    Trophy Points:
    18
    Google+:
    Ngeliatnya aja udah pusing

    Ngeliatnya aja udah pusing banget *kerja*
     
  7. Devita

    Devita Active Member

    Joined:
    Oct 11, 2014
    Messages:
    1,194
    Likes Received:
    43
    Trophy Points:
    48
    Google+:
    Wah nie script keren den, sampai mencakup file images n audionya juga *bagus*
     
  8. Devita

    Devita Active Member

    Joined:
    Oct 11, 2014
    Messages:
    1,194
    Likes Received:
    43
    Trophy Points:
    48
    Google+:
    Wah nie script keren den, sampai mencakup file images n audionya juga *bagus*
     
Loading...
Similar Threads - Htaccess Informasi penggunaan
  1. royger
    Replies:
    10
    Views:
    3,078

Share This Page