Apache Redirection With Masking (Without changing the Url)

Linux Server administrators frequently come across requirements from clients such that they want to redirect their site to another URL WITHOUT changing URL, this can be done by adding a rule in .htaccess file.

We can setup redirection for a domain without changing the url in the browser. For that open your .htaccess file and add the below code.

RewriteCond %{HTTP_HOST} ^DomainA.com
RewriteRule ^(.*) http://DomainB.com/$1 [P]

After adding this line into your .htaccess file, you will be able to go to DomainA.com/YourPage and it will show the content from DomainB.com/YourPage.

This trick works on Linux Servers running Apache Web server.



There are no revisions for this post.

Tags: , , , , , , ,

No comments yet.

Leave a Reply