Map a Separate Domain Name to a WordPress Page or Post

I had a client who wanted to map a domain name directly to a WordPress Page, and not show the WordPress URL.

For example, let’s say you had a WordPress blog with this Page:

But let’s say you want the URL of that post to be

Of course, you could do a simple redirect, but that would result in being shown as the URL in your browser, not the original domain name.

In this article, I’ll show you how to mask a WordPress page or post with a separate URL with completely different domain name.  Note, I am assuming in this article that you own the domain name that you want to use (i.e., “”), and that it is pointing to the root of your WordPress site.

My First Try

I a not a mod_rewrite expert, but I knew the answer lay there. After a lot of reading and tinkering, I came up with this code for my .htaccess file:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^airplanesarecool\.com$ [NC]
RewriteRule ^(.*)$ [NC,L]

This did do the redirect, but it did not mask the URL. That is, the WordPress URL was still showing up in the browser, not the desired domain name.

I Am The One That Masks

After more tinkering, I discovered that the original domain name was preserved only if I redirected to a file at the root level. It wouldn’t work for subdirectories (maybe one of you knows why?)

Armed with that knowledge, I changed my approach to redirect the URL to the raw “non-pretty” WordPress URL, which is basically index.html at the root level with a query string. Thus, I came up with this:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^airplanesarecool\.com$ [NC]
RewriteRule ^(.*)$ index.php?page_id=180 [NC,QSA]

This works! If you type in “” in the browser, it will display the page at, but keep your original URL! Great!!!

As I mentioned, you’ll need to point your domain name at your WordPress root directory. That is, point to

Next, place the code above the WordPress code in your .htaccess file at the WordPress root. That is, put it above the line that says:

#BEGIN WordPress

In the fourth line, specify the ID of your WordPress Page or Post. You can find the ID by viewing your Page or Post in edit mode and looking at the URL. It’s in there.

How it Works

The first line simply turns on the redirecting engine, and the second sets the base directory.

The third line is where the magic starts to happen. It says, “look at the ‘HTTP_HOST’ variable and see if it matches ‘’. The “[NC]” means the test is case-insensitive.

If this condition is met, the fourth line redirects the user to index.php?p=180, where 180 is the ID of the WordPress Page or Post. The “QSA” is needed to preserve query strings.

Is There a Plugin For This?

Since I first published this article, I found this plugin which seems to do what we need. Another is Page as a Subdomain. I haven’t tried these yet, so if you do, please let me know how they works for you!

That’s it! Let me know how this worked for you, or if you have any questions, or if you have any corrections or improvements. I am by no means an expert in mod_rewrite, but I hope to be some day. – Brian

46 thoughts on “Map a Separate Domain Name to a WordPress Page or Post

  1. Thank you! Found the plugin you mentioned in the comments and it was easy to set-up and does the job perfectly. Thanks for the tip!

  2. nginx way:

    server {
    listen 80;
    location / {

    you may need to explicitly allow CORS on proxied server:
    server {
    listen 80;

    location … {
    # for all locations add header as follows
    add_header ‘Access-Control-Allow-Origin’ ‘’;

    1. Hi Solo Jay,

      I found a WorPress plugin that seems to do this, but I’ve never tried it myself:

      Let me know what you think of it if you try it!

      Also, regarding your bigger goal, there are lots of plugins that turn Woocommerce into your own Etsy marketplace, basically:

      But note that the multiple domain mapping plugin notes say it doesn’t work with WooCommerce….


Leave a Comment or Ask a Question

This site uses Akismet to reduce spam. Learn how your comment data is processed.