Options +FollowSymLinks -Indexes -MultiViews
RewriteEngine On


############################################
#Redirect to www.

#RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
#RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

############################################
## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

############################################
## Never rewrite for not existing js|css|jpg|gif|png|jpeg|swf

RewriteCond %{REQUEST_URI} !^(.*).(js|css|jpg|gif|png|jpeg|swf)$

############################################
## Rewrite all other requests to index.phpz

RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]

############################################
## Deflate 

AddDefaultCharset UTF-8
<IfModule mod_deflate.c>
	SetOutputFilter DEFLATE
    AddOutPutFilterByType DEFLATE text/html text/plain text/xml text/css text/js text/javascript application/javascript
    <IfModule mod_setenvif.c>
        # Netscape 4.x has some problems...
        BrowserMatch ^Mozilla/4 gzip-only-text/html

        # Netscape 4.06-4.08 have some more problems
        BrowserMatch ^Mozilla/4\.0[678] no-gzip

        # MSIE masquerades as Netscape, but it is fine
        # BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

        # NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
        # the above regex won't work. You can use the following
        # workaround to get the desired effect:
        BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html

        # Don't compress images
        SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary
    </IfModule>

    <IfModule mod_headers.c>
        # Make sure proxies don't deliver the wrong content
        Header append Vary User-Agent env=!dont-vary
    </IfModule>
</IfModule>


############################################
## Set expire header for static contents

ExpiresActive On
ExpiresDefault A0

# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
ExpiresDefault A604800
</FilesMatch>

# 1 WEEK
<FilesMatch "\.(txt|xml|js|ico|css)$">
ExpiresDefault A604800
</FilesMatch>

# 1 WEEK
<FilesMatch "\.(jpg|jpeg|png|gif|swf)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>

# 1 WEEK
<FilesMatch "\.(txt|xml|js|ico|css)$">
Header set Cache-Control "max-age=604800"
</FilesMatch>
## Disable PHP|Perl|Ruby in Uploads Folder
RewriteRule ^public/uploads/.*\.(php|rb|py)$ - [F,L,NC]

<ifModule mod_headers.c>
        Header always set X-Frame-Options "ALLOW-FROM https://partsadmin.mynaghimotors.com/"
        Header always set X-Frame-Options "ALLOW-FROM https://staging.mynaghi.com/"
</ifModule>