0

Hi I am use Deployer to deploy a Craft CMS website. The site is symlinked to the directory called 'current'. I am using mod rewrite to remove the /current/public from the url in the document root like so:

RewriteEngine On
RewriteCond %{REQUEST_URI} !current/public/
RewriteRule (.*) /current/public/$1 [L]

And inside the current/public folder there is this htaccess to remove the index.php and create nice urls:

RewriteEngine On
# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]

Edit - Test

The following works to force HTTPS but I end with urls looking like: example.com/current/public/about etc

RewriteEngine On

RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]

# Send would-be 404 requests to Craft
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [NC]
RewriteRule (.+) index.php?p=$1 [QSA,L]

How can I adjust this to force the site to always use HTTPS?

Pedro
  • 1,148
  • 4
  • 16
  • 35

2 Answers2

0

This will redirected all http request to https. RewriteEngine On

RewriteCond %{SERVER_PORT} 80

RewriteCond %{HTTP_HOST} ^(www.)?yourdomainname.com

RewriteRule ^(.*)$ https://www.yourdomainname.com/$1 [R,L]

Hope this will help you

0

The following is what I managed to get working:

RewriteEngine on
RewriteRule ^(.*)$ current/public/$1
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=302,L]
Pedro
  • 1,148
  • 4
  • 16
  • 35