Got another problem. I want to force all connection to use https.
Here is my full httaccess
Code:
<IfModule mod_rewrite.c>
# Turn on URL rewriting
RewriteEngine On
# If your website begins from a folder e.g localhost/my_project then
# you have to change it to: RewriteBase /my_project/
# If your site begins from the root e.g. example.local/ then
# let it as it is
RewriteBase /
# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)
# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]
# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|opensearch\.xml|favicon\.ico|public|js|css)
# No rewriting
RewriteRule ^(.*)$ - [PT,L]
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L]
</IfModule>
Here is my vhost.conf
Code:
NameVirtualHost 127.0.0.2:443
<VirtualHost 127.0.0.2:443> # not the real ip
SSLEngine On
SSLCertificateFile /etc/httpd/ssl/httpd.pem
SSLCertificateKeyFile /etc/httpd/ssl/httpd.key
ServerAdmin admin@mysite.com
ServerName mysite.com
ServerAlias www.mysite.com
ErrorLog /web/errors/mysite
DocumentRoot /web/myb/htdocs
<Directory "/web/myb/htdocs">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>-
</VirtualHost>
If I access the site using
https://mysite.com it works and access over https using ssl
If I enter mysite.com on browser it is redirected to /var/www/html
My little workaround is to put an index.php with the content :
Code:
if(empty($_SERVER["HTTPS"])) {
$newurl = "https://" . $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
header("Location: $newurl");
exit();
} I tried some .httaccess redirect solutions but didn't work. I prefer not put them here because I was doing copy-paste without understanding them and is posible that some of my .httaccess file content to conflict with redirect rules.
BR