Apache – How to handle URL redirect based on a requested domain using .htaccess file?

This is how you handle the URL redirection based on a requested domain in Apache by using .htaccess file.

Requirements: Apache Module: mod_rewrite installed and enabled.

How to:

Open .htaccess file and add in one of the following codes.

This is what you do if you just want to simply point one domain (abc.com) to another (xyz.com):

And this is how you handle a redirect of a domain (abc.com) to a specific page on a different domain (xyz.com/page.html):

 

Facebook Comments