Skip to content

Instantly share code, notes, and snippets.

@aenigme
Created August 6, 2010 16:02
Show Gist options
  • Save aenigme/511531 to your computer and use it in GitHub Desktop.
Save aenigme/511531 to your computer and use it in GitHub Desktop.
Kohana htaccess file
RewriteEngine on
RewriteBase /
# Add www rule
# RewriteCond %{HTTP_HOST} ^example.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]
# Remove www rule
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
# Trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ $1/ [R=301,NC,L]
# Secure directories
RewriteRule ^(application|system) index.php/$1 [L]
RedirectMatch 404 /\.git(/|$)
RedirectMatch 404 /\.svn(/|$)
RedirectMatch 404 /css/(/|$)
RedirectMatch 404 /fonts/(/|$)
RedirectMatch 404 /images/(/|$)
RedirectMatch 404 /js/(/|$)
RedirectMatch 404 /temp/(/|$)
# Kohana bootstrap
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [QSA,L]
#Force PDF download
<FilesMatch "\.(?i:pdf)$">
ForceType application/octet-stream
Header set Content-Disposition attachment
</FilesMatch>
# Redirect old search page to new search page
# redirect 301 /search/index.html /foobar/search
# redirect 301 /search /foobar/search
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment