Redirect to a URL using .htaccess

Add the following code to your website’s .htaccess file to redirect to all requests to a different URL.

<IfModule mod_rewrite.c>
# Redirect to URL
RewriteCond %{HTTP_HOST} ^www.example.com(.*)$ [NC]
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]
# End Redirect to URL
</IfModule>

Comment

There is no comment on this post. Be the first one.

Leave a comment