Htaccess File


# activate the rewrite engine
RewriteEngine On

# Security ---

    # disable directory browsing
    Options All -Indexes

# Cache ---

    # 480 weeks
    <filesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
        Header set Cache-Control "max-age=290304000, public"

    # 2 DAYS
    <filesMatch ".(xml|txt)$">
        Header set Cache-Control "max-age=172800, public, must-revalidate"

    # unset cache for specific files
    <FilesMatch ".(html|pl|php|cgi|spl|scgi|fcgi)$">
        Header unset Cache-Control

# Deactivate the ETag ---

    Header unset ETag
    FileETag None

# Gzip ---

<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/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.*

# Not Found ---

    ErrorDocument 404 /github/raincms2/index.php?path=not_found

# Back-end ---

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{QUERY_STRING} (.*)
    RewriteRule ^admin(.*)$ admin.php$1?%1 [L]

# Front-end ---

    # files
    RewriteCond %{QUERY_STRING} (.*)
    RewriteRule ^files/(.*)/(.*) download.php?file_id=$1&name=$2&%1 [L,NC]

    # generate the google sitemap
    RewriteRule ^ajax/(.*)/(.*)/(.*)$ ajax.php?module=$1&action=$2&param=$3 [L,NC]

    # WYSIWYG Edit ---
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{HTTP_COOKIE} ^.*admin_check.*$ [NC]
        RewriteCond %{QUERY_STRING} (.*)
        RewriteRule ^(.*)$ edit.php/$1?%1 [L]

    # contents
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{QUERY_STRING} (.*)
    RewriteRule (.*) index.php/$1?%1 [L]
Exit mobile version