Mod_rewrite का उपयोग करना अनुशंसित तरीका नहीं है इसके बजाय वर्चुअल होस्ट और रीडायरेक्ट का उपयोग करें।
मामले में, यदि आप mod_rewrite का उपयोग करने के इच्छुक हैं:
RewriteEngine On
# This will enable the Rewrite capabilities
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
# This rule will redirect users from their original location, to the same
location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in
# httpd.conf or .htaccess context
संदर्भ: Httpd Wiki - RewriteHTTPToHTTPS
यदि आप 301 स्थायी पुनर्निर्देशन की तलाश कर रहे हैं, तो पुनर्निर्देशित ध्वज इस प्रकार होना चाहिए,
R=301
इसलिए रेव्रीलेर जैसा होगा,
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]