Posts Tagged Http Referer

How to reset the htaccess rules for sub folders

Normally htaccess rules applied to all folder and subfolder also, if we need to restrict one of the sub folder then we need to use the redirect condition like below

# subfolder
RewriteCond %{HTTP_HOST} ^example.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteCond %{REQUEST_URI} !^/website/
RewriteCond %{REQUEST_URI} !^/somefolder/
RewriteCond %{REQUEST_URI} !^/client/blabla/
RewriteRule (.*) /website/$1

that above code will apply redirect rules except the three folders “website”, “somefolder”, “client/blabla/”. but that one is hard to include all rules using the rewrite condition some times above code may help to exclude the directory.

At last i found one simple solution to avoid the sub folders using this code, we just need to create the “.htaccess” files and put the below code

RewriteOptions inherit

that above code will reset all rules from parent htaccess files so now we can easily install drupal / joomla inside the wordpress site else vice versa.

 

Posted in: Uncategorized, Web Developers/Designers Reference Guide

Leave a Comment (0) →

.htaccess code for web site speed optimization

# Enable GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</ifmodule>
# Expires Headers – 2678400s = 31 days
<ifmodule mod_expires.c>
  ExpiresActive On
  ExpiresDefault “access plus 1 seconds”
  ExpiresByType text/html “access plus 0 seconds”
  ExpiresByType image/gif “access plus 2678400 seconds”
  ExpiresByType image/jpeg “access plus 2678400 seconds”
  ExpiresByType image/png “access plus 2678400 seconds”
  ExpiresByType text/css “access plus 518400 seconds”
  ExpiresByType text/javascript “access plus 2678400 seconds”
  ExpiresByType application/x-javascript “access plus 2678400 seconds”
</ifmodule>
# Cache Headers
<ifmodule mod_headers.c>
  # Cache specified files for 31 days
  <filesmatch “\.(ico|flv|jpg|jpeg|png|gif|css|swf)$”>
  Header set Cache-Control “max-age=2678400, public”
  </filesmatch>
  # Don’t cache HTML
  <filesmatch “\.(html|htm)$”>
  Header set Cache-Control “max-age=0, private, must-revalidate”
  </filesmatch>
  # Cache PDFs for a day
  <filesmatch “\.(pdf)$”>
  Header set Cache-Control “max-age=86400, public”
  </filesmatch>
  # Cache Javascripts for 31 days
  <filesmatch “\.(js)$”>
  Header set Cache-Control “max-age=2678400, private”
  </filesmatch>
</ifmodule>

Other tips to optimize your website using .htaccess snippets

Force trailing slash

Prevent Image hotlinking

Redirect mobile devices

Posted in: Uncategorized, Web Developers/Designers Reference Guide

Leave a Comment (0) →