Skip to content

Instantly share code, notes, and snippets.

@sercey
Last active November 18, 2015 00:02
Show Gist options
  • Save sercey/db54066db2515f8bcc7f to your computer and use it in GitHub Desktop.
Save sercey/db54066db2515f8bcc7f to your computer and use it in GitHub Desktop.
Yii 2 Basic Force SSL htaccess
# Mod_Autoindex
<IfModule mod_autoindex.c>
# Disable Indexes
Options -Indexes
</IfModule>
# Mod_Rewrite
<IfModule mod_rewrite.c>
# Enable symlinks
Options +FollowSymlinks
# Enable mod_rewrite
RewriteEngine On
# SSL redirect
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# WWW redirect
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Frontend redirect
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ web/$1 [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment