Htaccess redirect to www code example
Example 1: htaccess redirect to https
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^yourdomain\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.yourdomain\.com
RewriteRule .* https:
Example 2: redirect htaccess non www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http:
Example 3: htaccess redirect to https
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https:
Example 4: htaccess redirect to html page
RedirectMatch 301 ^/blog/about /blog/about.html
Example 5: https and www htaccess redirecr
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https:
Example 6: How to redirect non-www URLs to www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http: