Skip to content

Instantly share code, notes, and snippets.

@codfish
Created August 14, 2014 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codfish/c395d38d951ba4e73b9c to your computer and use it in GitHub Desktop.
Save codfish/c395d38d951ba4e73b9c to your computer and use it in GitHub Desktop.
The RewriteCond directive just describes an additional condition for a RewriteRule directive. So RewriteCond must always be associated with a RewriteRule. Source: http://stackoverflow.com/a/2102189
; Now this rule is applied if the pattern of the RewriteRule matches the current request
; URL (per-directory path stripped before) and if the condition is fulfilled.
;
; In this case the condition is only true if when mapping the request URL
; to the filesystem it matches either an existing file with the file size
; greater than 0 (-s), or a symbolic link (-l) or a directory (d). So your rule will
; be applied for any URL (^.*$ matches anything) that can be mapped to something
; existing in your filesystem. The substitution - just means to not change anything.
; And the NC (no case, case insensitive, useless in this context) and L (last rule if applied)
; are flags that modify either the pattern, replacement or the execution of the rule.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment