3

I will be designing and developing a website for a client but want to allow the client to add content while I am working on the design and development of the site so that it is pretty mich done by the time I am finished.

Currently, I use XAMPP on port 81 so my project URL looks something like

http://localhost:81/projectname

My wp-config file has all the settings I need to the remote DB and yet, when I run the

http://localhost:81/projectname 

URL it constantly redirects me to

http://localhost/projectname.

I've removed all htaccess files thinking the problem was there but that didn't work. My ISP suggested opening port 3306 which I have done but that's not done the trick either.

I don't know if it has to do with port 81 on Xampp perhaps?

EDIT: General settings link through to the online version of the site so

Site Address = http://example.com

WP Address = http://example.com

Many thanks

6
  • What are your URL settings in Settings->General?
    – s_ha_dum
    Oct 11, 2013 at 14:59
  • Try to check your apache configuration file also in your Xampp installation. You can check on this link how to setup multiple sites using xampp, which can help you test if the problem is Xampp: kuppalli.wordpress.com/2011/01/24/… Oct 11, 2013 at 15:20
  • I've made an edit to the above question shadum, thanks Oct 11, 2013 at 15:37
  • Sorry? Your configuration settings link to an external site? That isn't ever going to work correctly. I am very confused by what you are doing now.
    – s_ha_dum
    Oct 11, 2013 at 15:41
  • Thanks Camilo. I tried this thinking that adding port 3306 might do the trick but it didn't. I'm not having a problem with multiple projects but rather, a problem running a local project that connects to a remote DB. Oct 11, 2013 at 15:45

2 Answers 2

3

I think s_ha_dum is in the right track, but I think he got it backwards.

You want to:

  1. develop/design locally
  2. connect to the REMOTE database and work with his content?

You need a remote (staging) installation of WordPress, where the client can create/enter his content.

You need your local WordPress site (localhost) to point to the remote database, to grab the content he is using.

So, you would have your http://example.com/wordpress set up for the client to edit - just even with a vanilla WP install. This site would be connected to it's own database.

Your localhost site would have the REMOTE site's database credentials, with the DB_HOST set to http://example.com, or whatever the mySQL path is if it's accessed another way through your hosting provider.

On your local site, keep the WP_SITEURL and WP_HOME set to localhost. Otherwise, you'll get redirection loops.

8
  • Thanks Eric that is what's been happening and what you are suggesting is what I would like to achieve but I kept getting the redirect problem. I will combine both of your solutions and get back to you :) Thanks again! Jan 29, 2014 at 16:00
  • Sorry, it's WP_SITEURL, not WP_SITE_URL. If that doesn't work, you may need to define define('WP_RELOCATE', true); in your wp-config.php file, log in, then remove the line. Feb 5, 2014 at 15:38
  • Thanks Eric, not had time to spend on it again but I will as soon as I get a moment. Feb 5, 2014 at 19:08
  • Hi Eric. On a new project now and tested this. It works super well but really slow. Is there a way to speed it up perhaps? Feb 25, 2014 at 10:24
  • You only need the relocate definition for the first log-in when transferring a website. Remove it once it's working properly. :) Feb 25, 2014 at 14:59
3

Is there no way to pull the content to a localhost site just to get the content onto the site so that I can work on the development of the site while the client adds the content to the live DB?

If the remote server supports it, you can connect to the remote database. Just set your connection constants correctly:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'database_name_here' );

/** MySQL database username */
define( 'DB_USER', 'username_here' );

/** MySQL database password */
define( 'DB_PASSWORD', 'password_here' );

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

You will almost certainly also have to set these on the local install:

define( 'WP_SITEURL', 'http://example.com/wordpress' );
define( 'WP_SITEURL', 'http://example.com/wordpress' );

I can almost guarantee that you are still going to have issues, not to mention that changes you make are to the live server.

There are other potential solutions, like database mirroring, but that would be off-topic here and I've never done it.

My advice is to just copy the live database to your local server at the project start and do not try to sync the databases or otherwise connect the development site with the live one. You are asking for trouble. WordPress does not have a sharp content/config separation in the database.

12
  • Thanks Shadum, I might go that route of constantly grabbing a new version of the live DB...and don't worry, the live DB is hidden behind a URL until the actual site goes live :) Oct 11, 2013 at 17:36
  • Nope, didn't work. Thanks for the effort though Shadum Oct 11, 2013 at 17:39
  • My advice is the last paragraph, please note.
    – s_ha_dum
    Oct 11, 2013 at 17:52
  • Thanks Shadum...will go this route on your last paragraph Nov 7, 2013 at 6:02
  • @SixfootJames : you accepted this answer long ago, but have now unaccepted it and have not accepted an alternative. Why?
    – s_ha_dum
    Jan 20, 2014 at 14:25

Your Answer

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

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