Http to Https redirection

Avatar
  • Answered
https://www.inmotionhosting.com/support/website/ssl/how-to-force-https-using-the-htaccess-file
I used this article mention code for my site, but it's not working fine for me, I have to fixed few problems,
1) Always need to search engine links like this " https://www.example-test.com " with https and www.
2) My site have separate mobile site using AMP, When I add article mention .htaccess codes mobile site not working, Need to link like this " https://www.m.example-test.com "

My codes are below
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\-test\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example\-test.com/$1 [R,L]

RewriteCond %{HTTP_HOST} ^www\.example\-test\.com$
RewriteRule ^index\.html$ "https\:\/\/www\.example\-test\.com\/" [R=301,L]
Avatar
johnpaulb-imhs1
Hello,

Thank you for your question regarding https redirection. If you are using a CMS (such as WordPress, Joomla, Drupal, etc.), I recommend using a plugin or extension to handle redirects. This is because they also rely on .htaccess rules and adding them directly can cause issues.

Also, review your mobile redirect rules (to "www.m.example-test.com") to ensure they are not interfering with the new rewrites you are adding.

Thank you,
John-Paul