Redirect domain to subdirectory without changing URL

Redirect domain to subdirectory without changing URL

Linux Reseller Hosting

The simple way to redirect your primary domain to a sub folder without change the URL


A)  Redirect and keep everything after the URL

Show all of the same content on one URL as you would another.

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.

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?

Adding this line into your .htaccess file, you will be able to go to and it will show the content from

B) Redirect a domain to a specific url

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]


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.

C)  Re-directing an IP address

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

Note: 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.


Windows Shared Hosting