jonathancross/ - Htaccess File


AddDefaultCharset utf-8
DefaultLanguage en-US
AddType application/xhtml+xml .xhtml
# AddType text/xml .xhtml

DirectoryIndex index.shtml index.xhtml index.html index.cgi

# Secure htaccess file
<Files .htaccess>
 order allow,deny
 deny from all

# Protect against DOS attacks by limiting file upload size
LimitRequestBody 10240000

# Minimize image flicker in IE6
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/png A2592000

# Custom error pages
ErrorDocument 404 /error.html
ErrorDocument 500 /error.html

# Clean URLs
# TODO: I think RewriteRule never contains query string, so [^?]+ could be just .+.
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Skip all rules if normal file request.
  # We need this first condition to exclude urls with a non-empty query string.
  RewriteCond %{QUERY_STRING} !.
  RewriteCond %{REQUEST_FILENAME} -f
  RewriteRule . - [last]

  # Force 301 on legacy params.
  # Consider just marking as gone:
  # RewriteRule ^jcdsee.cgi - [gone,last]
  # Redirect `pic` to single:
  RewriteCond %{QUERY_STRING} pic=([^&]+)
  RewriteRule ^jcdsee.cgi /single%1? [redirect=301,last]
  # Redirect `cur_url` to folder:
  RewriteCond %{QUERY_STRING} cur_url=([^&]+)
  RewriteRule ^jcdsee.cgi %1? [redirect=301,last]

  # Short 'go' URL redirect.  See #29.
  RewriteRule ^go/(.+)$ /jcdsee.cgi?go=$1 [last]

  # DIRECTORY: Normalize directories to have trailing slash: /
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ([^/])$ /$1/
  # DIRECTORY: Captures any real directory paths under /pics/ and converts to parameters.
  RewriteRule ^(pics[^?]*)/$ /jcdsee.cgi?pic_path=/$1/ [qsappend,last]

  # Force trailing slash if there is no '.' in the final segment (meaning it ignores file names).
  # This works most of the time, but will not catch directories with a '.' in the name.
  # Would be better to use some RewriteBase magic to test for dir or file like above.
  RewriteRule (.*/[^?.]+[^?/])$ /$1/ [redirect=301,last]

  # Display modes
  RewriteRule ^(single|thumb|slide|list)/([^?]+)$ /jcdsee.cgi?pic_path=/$2&display_mode=$1 [qsappend,last]

  # /jcdsee/ DIRECTORY: Prevent file listing here.
  RewriteRule ^jcdsee/$ / [redirect=301,last]


On Github License


Download PDF of Htaccess file