Last active
August 28, 2018 05:45
-
-
Save loonies/1058632 to your computer and use it in GitHub Desktop.
Kohana .htaccess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turn on URL rewriting | |
RewriteEngine On | |
# Installation directory | |
RewriteBase / | |
# Protect hidden files from being viewed | |
<Files .*> | |
Order Deny,Allow | |
Deny From All | |
</Files> | |
# Protect application and system files from being viewed | |
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L] | |
# Allow any files or directories that exist to be displayed directly | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
# Rewrite all other URLs to index.php/URL | |
RewriteRule .* index.php/$0 [PT] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Max file upload size | |
php_value upload_max_filesize 10M | |
php_value post_max_size 10M | |
php_value memory_limit 64M | |
# Disable PHPSESSID in the URI | |
php_value session.use_trans_sid Off | |
# Disable directory browsing | |
Options -Indexes | |
# Redirect non-www to www | |
RewriteCond %{HTTP_HOST} !^www\. [NC] | |
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
# Redirect www to non-www | |
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] | |
# Redirect other sub domains to the main domain (use only if set by VirtulaHost ServerAlias) | |
RewriteCond %{HTTP_HOST} !^www\.other\.com | |
RewriteRule ^(.*)$ http://www.main.com/ [R=301,L] | |
# Redirect non-ssl to ssl | |
RewriteCond %{HTTPS} off [NC] | |
RewriteRule ^(.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# Redirect non-ssl directory (e.g. admin, checkout) to ssl | |
RewriteCond %{HTTPS} off [NC] | |
RewriteRule ^admin https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# Allow direct access to the static files, | |
# if the file does not exists it will prevent another round trip to the application | |
RewriteRule ^(?:static|media)\b.* - [L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Turn on URL rewriting | |
RewriteEngine On | |
# Installation directory | |
RewriteBase / | |
# Protect hidden files from being viewed | |
<Files .*> | |
Order Deny,Allow | |
Deny From All | |
</Files> | |
# Protect application and system files from being viewed | |
RewriteRule ^(application|modules|system)\b - [F,L] | |
# Allow any files or directories that exist to be displayed directly | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteCond %{REQUEST_FILENAME} !-d | |
# Rewrite all other URLs to index.php/URL | |
RewriteRule .* index.php/$0 [PT] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# It happens that default 'RewriteRule' doesn't work on some host. | |
# Note that full URL has to be preserved including the query string. | |
# Documenting rules that worked for the future reference. | |
# Rewrite all other URLs to index.php/URL | |
RewriteRule .* index.php/$0 [PT] | |
RewriteRule ^(.*)$ index.php?/$1 [PT,QSA] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Redirect www to non-www and use SSL for admin pages | |
RewriteCond %{HTTPS} off [NC] | |
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^admin https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] | |
# Redirect www to non-www | |
RewriteCond %{HTTPS} on [NC] | |
#RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, man. Struggled with this for like two hours.