How to redirect a domain without changing the URL

How to redirect a domain without changing the URL

Example 1: Redirect and keep everything after the URL

The first option will show all of the same content on one URL as you would another. For example, if you just changed your domain to, but you still have plenty of visitors coming to, you would use this to show them all of the existing content that is located on the new domain, without the need to update both websites.

To do this, you would modify your .htaccess file for the domain that your users will go to, and insert these lines of code:

RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*)$1 [P]

What does the above redirect do?
After adding this line into your .htaccess file, you will be able to go to and it will show the content from

Example 2: Redirect a domain to a specific url

There is another way you can do your redirect to show a specific URL, but keep the domain the same as well. If you want visitors to go to with a specific page in mind when doing so, you may use this code:

RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*) [P]

You would use this method if, for example, you had an external blog such as one on or maybe a shopping cart on that you want people to visit your domain without fully hosting the domain there. Now, visitors can access your site using your domain, but see the content of an external URL.

Example 3 Re-directing an IP address

Occasionally, there will be a request to re-direct an IP address to a specific URL. The following code shows how this can be done in the .htaccess file.

# Redirect all IP address (replace the ## with the IP address numerals) to same
RewriteCond %{HTTP_HOST} ^##\.##\.##\.##
RewriteRule (.*)$1 [R=301,L]

Leave a Reply

Your email address will not be published. Required fields are marked *