.htaccess redirect all URLs and migrate domain.com/xyz to xyz.com

I’m migrating a sub-site to its new domain and would like to redirect all the existing links to the new domain, while keeping all of the URL parameters

Examples:

Read More
domain.com/xyz --> xyz.com
domain.com/xyz/link.php --> xyz.com/link.php
domain.com/xyz/folder/link.php --> xyz.com/folder/link.php

Thanks

Related posts

Leave a Reply

2 comments

  1. You can put this code in the beginning of your htaccess (in document root folder of domain.com) just below RewriteEngine On line (or RewriteBase if present)

    RewriteRule ^(xyz)(.*)$ http://$1.com$2 [R=301,L]