Can I use URL rewrite to display different domain name?

(Rob) #1

Hi everyone,
I have a question about using URL rewrite rules and can this feature be applied in my case.

I am interested in creating community site ( for this example) for 2 types of users, here are the details:

  • Type A (vendors)
  • Type B (general users)
  • Site uses BuddyPress so each user can have a profile plus other community features (mail, write on users wall, etc)
  • Site will specifically NOT use WP Multisite feature

Part 1
So that’s the setup. I’m interested in Type A users to have the option to have their profile url come up under their own domain name… So a user is cruising the site and comes across a vendor they want to check out. They click on a link to them and it takes them to their BuddyPress profile/page hosted on ( for example) but the URL is rewriten to show

The other part is when a user enters into the browser they should be taken to the page. But that’s not handled by URL rewrite, that would be handled by redirecting the domain name using MX records I believe. Correct me if I’m wrong.

A couple of questions:

  1. Can URL rewrite do this, specifically display a totally different domain url?
  2. As far as I understand URL rewrite happens in the background so it should not be noticed by search engines for example. Will this page be treated just like any other page by search engines?

Any feedback about this route of using URL rewrite to achieve this would be appreciated.

(Leland Fiegel) #2 Or

I can’t wrap my head around how this would work with “true” DNS.

In any case, a simple way to do it would be to just instruct the owner of to set up an iframe to the relevant page on

This isn’t exactly a “rewrite” but will (appear to) accomplish the same end result.

MX records are related to email. The “MX” stands for “mail exchanger” …so no, this wouldn’t have anything to do with MX records.

This would be handled by the same aforementioned iframe, so no additional steps are necessary here.

However, it sounds like you want the URL to update in the address bar too. With an iframe, the URL would still be while the relevant page loaded within.

I suppose you could load a different type page depending on the referring URL. An iframe if you’re referred by, a straight redirect if you’re not (i.e. accessing directly).

I’m going to trust you have a good reason to do something like this. My initial thought is this seems to be a strange and confusing way to handle things, no matter what path you use to get there.

Imagine the user confusion if they click a vendor profile page, find themselves on a new domain, but appear to be on the exact same site.

Have you ever seen another site that does anything like this? If not, maybe there’s a good reason why.

(Rob) #3

My mistake, yes XM pertains to email. Not sure what I was thinking.

Yes I would like the URL to update to so an iFrame would not work in this case.

@leland I totally understand that this is a far-fetched way of going about what I’m trying to achieve, and maybe what I’m going for isn’t even possible. This was just my idea I had with my limited knowledge of Apache and URL rewrite feature.

No, I haven’t seen any site do this but if it worked it would be just the thing I’m looking for in this unique case.

Thanks for the reply :slight_smile:

(Russell Heimlich) #4

Yes this is possible but it is kind of complicated. You wouldn’t use rewrite rules per say but it is possible to make WordPress answer requests with more than one domain name for a single site install.

So what do you need to do?

  1. Change your DNS records so and point to the same server.
  2. Configure the server so requests to different domains point to the same root directory where WordPress is installed. “Virtual Hosts” is a good phrase to Google.
  3. Configure WordPress to dynamically change the URL of the blog depending on the domain used to access the site. Here is one way to do it:
  4. Custom logic on your end to handle redirecting to and from domains. You wouldn’t want’s content to be accessed via for instance.

I’ve done something vaguely similar. I wanted to be able to have an entire domain run through a CDN and to do that I needed to add logic about when to bounce to the www version of a URL which goes through the CDN and when to redirect to the bare domain name which is used for accessing /wp-admin/ The code for that is here at

(Rob) #5

@kingkool68 I’m glad to hear that there is a way to achieve this. It’s beyond my scope at this time but I will look into the various parts of making this work.