17

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?

13
+150

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.

2

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 – Thiago Belem Mar 24 '14 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 '14 at 18:54
  • Thats the point, I can't use preview links with "admin." because they would only work on the "www." – Thiago Belem Mar 24 '14 at 23:00
  • You could use preview_post_link filter to adjust the URLs. – Dom Mar 25 '14 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 '14 at 17:56
1

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

http://tec.libertar.se/how-to-host-wordpress-admin-on-a-seperate-domain-and-subfolder/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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