In this article, we will give you 2 ways in how you can go about redirecting your site to another URL, without changing the domain.

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]

If you are using the file manager in cPanel, be sure that you have the option to show hidden files selected.

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]

Stipulations / Please read

Warning: If using the first option, search engines such as Google or Bing will see multiple sites with the same content and can cause ranking drops in one, or both of the sites. From an SEO standpoint, your best option is to create 301 redirects instead.

If you opt for the second option, and are using absolute links on your site (meaning your links go to the full URL and not just an individual file) any links will go to the original site that is associated with that link.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Can I use .htaccess to load my site from a different folder?
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-07-03 2:08 pm

I wanna know where should I put this code?

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

Thank you

9,968 Points
2014-07-03 2:14 pm
Hello mo,

You would want to place that code towards the top of your .htaccess file.

You also want to make sure that the Apache Rewrite engine is on, so the full code would look like:

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

Let us know if that works!

- Jacob
n/a Points
2014-08-08 12:01 pm

I've got this at the top of my .htaccess, but it's not working. :(


# Turn on the Rewrite EngineRewriteEngine OnRewriteCond %{HTTP_HOST} ^tomorrow.coe.uga.eduRewriteRule ^(.*)$1 [P] 
10,207 Points
2014-08-08 12:42 pm
Hello Daniel,

Thank you for your question. Your code looks pretty accurate, but you may have to add the $1 to the rewrite condition. For example:

# Turn on the Rewrite Engine
RewriteEngine On
RewriteCond %{HTTP_HOST} ^$1
RewriteRule ^(.*)$1 [P]

If you have any further questions, feel free to post them below.
Thank you,

2014-08-08 12:57 pm
Still didn't work. :\

It's always me with the "simple" solutions failing. I swear my career is 2 years behind because of technical glitches outside my control. :)
10,207 Points
2014-08-08 1:33 pm
Hello Daniel,

Thank you for the additional information. Since it depends on your actual site, there is most likely something inferfering with the code.

For example, if you are using a CMS such as Wordpress, or Joomla, or Concrete5, they have rules in place already.

You could also have other rules in the .htaccess causing problems, you should check them as well.

Can you provide a link to the website so we can test it out?

If you have any further questions, feel free to post them below.
Thank you,

n/a Points
2014-07-28 11:12 am

How is this different from doing a plain redirect? Is it possible to show contents from DomainB but show DomainA url?

10,207 Points
2014-07-28 11:33 am
Hello garry,

Thank you for your question. By "plain redirect," I think you mean creating a redirect in your cPanel. This just creates a redirect such as: ---->

To show contents from DomainB but show DomainA url there are 2 options:

Park domain

Redirect Using .htaccess file

If you have any further questions, feel free to post them below.
Thank you,

n/a Points
2014-08-27 5:39 pm


For the moment i am using DirectAdmin, but acting as my own reseller i think i own full access to

The goal is to show the content of but the URL bar should simply state :

For the moment there is nothing configured in, but in future i might want to install a WordPress site, so that i can show more pages than just the content of

I like your idea of the second option in the article.  But don't know what to put in "path to get there [p]"

Can you type it out for me ?

Many thanks in advance.

Here's my take :


RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*) [P]
17,716 Points
2014-08-27 6:08 pm
Hello Peter,

The path you're referring to has to do with the webpage that you're trying to point to. So, if the page is in a certain folder, then path would look like this: I hope that helps explain the issue.

Arnel C.
n/a Points
2014-10-01 9:55 pm



I have a and changed my url to As i had maintained urls friendly, i want visitors on going to to be redirected to, as the content and url are the same, just changed by domain.

Is it this that is covered on Example 1?

10,207 Points
2014-10-02 9:31 am
Hello Ricardo,

Thank you for contacting us today. Yes, that is what is is covered in Example 1: Redirect and keep everything after the URL.

If you have any further questions, feel free to post them below.

Thank you,
n/a Points
2014-11-08 3:44 am

Example:1 not working....i Want to redirect my domain to keeping rest of the URL same also changing with the new URL in address bar. But m failed....Any help ?? Thanks in advnace...

20,113 Points
2014-11-10 10:29 am
Hello Ashish,

I tried the code you referenced on my server and it worked fine. This code is intended to allow a domain name different from the primary to display the content of the primary under the second name. For example, if your primary domain name is '' and you want to allow '' to be used and show that same data, you would set it up like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^
RewriteRule ^(.*)$1 [P]

Setting it in reverse order causes a proxy error on the server.

Kindest Regards,
Scott M

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

14 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!