HTACCESS Rewrite URL - Example code to redirect HTTP to HTTPS and redirect non-www to www URL using .htaccess file. Use RewriteCond and RewriteRule in .htaccess to redirect all HTTP & non-www requests to HTTPS & www URL.