redirect to another page htaccess 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://yourdomain.com%{REQUEST_URI} [R=301,L]

Example 2: htaccess redirect to html page

RedirectMatch 301 ^/blog/about /blog/about.html

Example 3: .htaccess redirect to https

RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yourdomain.com/$1

Tags:

Misc Example