Article Image
read

You may want to redirect domain A to domain B (main URL):

  • A: http://awesomedomain.com/contact-me
  • B: http://awesomedomain.io/contact-me

Create a .htaccess on your webserver, in the www folder (of domain A):

RewriteEngine on
RewriteCond %{HTTP_HOST} ^awesomedomain.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.awesomedomain.com [NC]
RewriteRule ^(.*)$ http://awesomedomain.io/$1 [L,R=301,NC]
  1. RewriteEngine on : activation of the rewrite engine.
  2. RewriteCond %{HTTP_HOST} ^awesomedomain.com [NC,OR] : rule to check for domain A
  3. RewriteCond %{HTTP_HOST} ^www.awesomedomain.com [NC] : rule to check for sub-domain A
  4. RewriteRule ^(.*)$ http://awesomedomain.io/$1 [L,R=301,NC] : redirection rule
  • ^(.*)$ : $1 is the right side of the URL (contact-me).
  • New domain for the redirection and add the page to find - $1.
  • Type of redirection : 301, permanent redirection.
Blog Logo

Florent Bertiaux

I'm a blogger


Published

Image

I learned something new

A blog from @kxrz - Dev tips and tricks

Back to Overview