Last active
September 21, 2017 18:35
-
-
Save mssoylu/4d45381443ba538842867fdc29934164 to your computer and use it in GitHub Desktop.
SSL Symfony include redirect to https
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
# Symfony3.2 Virtualhost | |
# .htpasswd | |
# PHP cancel for directory | |
# Hide uploaded files physical paths | |
ServerSignature Off | |
ServerTokens Prod | |
<VirtualHost www.domain.com:80> | |
RewriteEngine On | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] | |
</Virtualhost> | |
<VirtualHost domain.com:80> | |
RewriteEngine On | |
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L] | |
</Virtualhost> | |
<VirtualHost domain.com:443> | |
ServerName domain.com | |
ServerAlias www.domain.com | |
SSLEngine On | |
SSLCertificateFile "/etc/apache2/ssl/domain.com.crt" | |
SSLCertificateKeyFile "/etc/apache2/ssl/domain.com.key" | |
DocumentRoot /var/www/basefony/root/web | |
# <Directory "/var/www/basefony/root/web/uploads"> | |
# AllowOverride None | |
# RemoveHandler .php .phtml .php3 | |
# RemoveType .php .phtml .php3 | |
# php_flag engine off | |
# </Directory> | |
# Hide physical paths of uploaded image files | |
# <Directory /var/www/basefony/root/web/uploads/avatars> | |
# Order allow,deny | |
# Deny from all | |
# </Directory> | |
SetEnv SYMFONY_ENV dev | |
# For secured upload dir | |
<Directory "/var/www/basefony/root/web/uploads"> | |
AllowOverride None | |
Options -ExecCGI | |
</Directory> | |
<Directory /var/www/basefony/root/web> | |
# Options Indexes Multiviews FollowSymLinks | |
# AuthType Digest | |
# AuthName "Demo" | |
# AuthUserFile /etc/apache2/.htpasswd | |
# Require valid-user | |
DirectoryIndex app_dev.php | |
AllowOverride None | |
<IfModule mod_expires.c> | |
ExpiresActive on | |
ExpiresByType image/jpg "access plus 1 month" | |
ExpiresByType image/jpeg "access plus 1 month" | |
ExpiresByType image/gif "access plus 1 month" | |
ExpiresByType image/png "access plus 1 month" | |
</IfModule> | |
RewriteCond %{HTTP_USER_AGENT} libwww-perl.* | |
RewriteRule .* ? [F,L] | |
<IfModule mod_rewrite.c> | |
RewriteEngine On | |
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | |
RewriteRule ^(.*) - [E=BASE:%1] | |
RewriteCond %{ENV:REDIRECT_STATUS} ^$ | |
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L] | |
# If the requested filename exists, simply serve it. | |
# We only want to let Apache serve files and not directories. | |
RewriteCond %{REQUEST_FILENAME} -f | |
RewriteRule .? - [L] | |
# Rewrite all other queries to the front controller. | |
RewriteRule .? %{ENV:BASE}/app.php [L] | |
</IfModule> | |
</Directory> | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment