php.htaccessaltorouter

htacess rewrite for AltoRouter to include redirect to https


I'm using Altorouter which requires the following in htacess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]

This is working just fine but I also need to redirect http to https. I found examples online but all my efforts to combine the two have failed. How would I combine the top snippet with this?

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://example.com/$1 [R]

Solution

  • Try with below,

    RewriteEngine on
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://yourdomain.com/$1 [R=301,L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]