Currenly I have a client that has a WordPress running on, let's say, www.example.com.

I'm working on a new version using another technology/language that will be hosted on another server.. But the administration (WP) and the database will stay on old server.

So basically I will need to point the www.example.com to the new host (no problem here) and create a subdomain like admin.example.com that will point to the old server with the WP installation.

I'm afraid that this will make a mess on the database while storing options and guids for posts and attachments URLs... They will be stored as admin.example.com and not www.example.com, am I right?

How to make the wp-admin run on admin.example.com and store URLs on the database as www.example.com? This would work for the preview links too?

  • I'm not sure but perhaps this thread can be useful: wordpress.org/support/topic/login-subdomain? Mar 23, 2014 at 19:15
  • @KristerAndersson the problem wasn't solved on the topic, and the links are 404 :( Mar 24, 2014 at 15:59
  • As this sounds interesting I did some searching and realized that this is pretty hard to achieve. Unfortunately I don't have the time to try it out myself. Anyway, it seems like someone got at least something similar working.
    – kraftner
    Mar 28, 2014 at 11:16
  • @thiago Belem, would you please let me know how you have resolved it?
    – Nair
    Aug 18, 2021 at 12:02

3 Answers 3


Easy solution would be adding this line to your wp-config.php of your admin server code.

define( 'WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME']);

Then you can access it without modifying the database option.

  • Works great! Wordpress.org states that this is a little bit insecure, but the only way to access my admin portal is from a VPN, and the original domain has the "/wp-admin/" path blocked; so, this is great for this use case! :)
    – Luis Lopez
    Aug 13, 2021 at 3:51

What I would do (I was actually doing that many times) is:

  • Change the domain name for the existing WP installation using, for example, this tool. Then, everything on your old site will get the "admin.example" links.
  • Change the URLs back when retrieve DB records to use on the new site. When I was doing that, I never accessed the "admin" DB directly. Instead, I had a script that was taking only the tables and records I needed and copied from "admin" to "www" servers.
  • This would be my last resource... Because this would break, for example, preview links inside the admin Mar 24, 2014 at 15:53
  • @TiuTalk No, everything in WordPress will work. The preview links will have the "admin" URLs, and will work. But, on the "www" site, you will replace the "admin" part with "www".
    – tivnet
    Mar 24, 2014 at 18:54
  • Thats the point, I can't use preview links with "admin." because they would only work on the "www." Mar 24, 2014 at 23:00
  • You could use preview_post_link filter to adjust the URLs.
    – Dom
    Mar 25, 2014 at 21:20
  • @TiuTalk You will have two parts of your application: A) the admin part, WP-based, will have the admin.example.com URL, and all links in it, including preview links will have the admin.example.com URLs. B) The production part, with the www.example.com URL, not WP-based, but your "other technology" will have all URLs starting with "www" instead of "admin" because when you transfer DB from "admin" to "production", you will replace "admin" with "www". Why won't this work?
    – tivnet
    Mar 29, 2014 at 17:56

I figured out how to do this with pure Apache server configuration, no need to customize WordPress settings...


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.