Wordpress local server to live host

2020-04-28 09:56发布

I am developing a wordpress site. I uploaded the files(wordpress) to my live host. So my new live url site for my wordpress like this sample url http://mywordpress.com/, the display seems to be fine, but when I start browsing the menus page will be redirected to my local server, instead of http://mywordpress.com/about-us/ it went to my localhost like http://localhost/mywordpress/about-us

So when I checked the page source all the links including the stylesheet is link to my local. even though I use this code

<link href="<?php bloginfo('stylesheet_url'); ?>" rel="stylesheet" type="text/css" media="all" />

Its kinda weird... but anyone knows how to configure this?

标签: php wordpress
4条回答
兄弟一词,经得起流年.
2楼-- · 2020-04-28 09:56

The reason behind this, After you move wordpress site from local server to live you not changed the site url and home address.So, when ever you try to open your site in real server it will redirect back to your local server.You need to open PhpMyAdmin Tool in Cpanel or FTP and select your database then open wp_options table.

In wp_options table change the value of site url and home.

Now your problem will solved.

查看更多
男人必须洒脱
3楼-- · 2020-04-28 10:07

It sounds to me like your database may be using old values for your url's.

For a quick solution that may or may not solve your issue, try http://www.velvetblues.com/web-development-blog/wordpress-plugin-update-urls/ . It's a great plugin. If not... here are my bullet proof instructions for transferring from local to online.

I've migrated from local to online hundreds of times and I think most tutorials on wordpress migration are overly complex. Here's my method (assuming you already have a fresh wordpress installation and database)

  1. Go to phpMyAdmin for your local server and export your database (but not as a file)... just get the straight SQL text and copy it.

  2. Paste that code into dreamweaver, text editor, coda or any plaintext word processor that can do a search and replace. Then search for "http://MyOldWordpressUrl.com/wordpress" (make sure there is NO slash after the final directory) and replace with "http://MyNewWordpressUrl.com/wordpress". Obviously don't include the quotation marks. Make sure your old wordpress URL is correct. You can double check in admin -> general settings.

  3. Get into your control panel for your online hosting and go to the database for your new wordpress install (this should be a brand new installation where you haven't yet created any posts or input any data-- just what wordpress gives you). Export the database and save it as a file (just in case). Now drop all the tables. Click YES when it asks you if you're sure. Then click on the SQL icon (should be in the upper left hand corner of the left sidebar). This should open a new window. Now paste in your code from step 2 and click GO.

  4. Transfer your theme folder via FTP.

  5. Right now you should go to the new wordpress install's wp-admin. Your same User Name and password will apply. Go to "add a post" and add any image from your computer... wait for it to upload, now delete it. This step is to have the server create the uploads folder to be 100% certain is registered by wordpress and set to the correct permissions. I've wasted hours before by transferring the uploads folder directly by FTP, so don't do it.

  6. Step 5 created an uploads folder in FTP, now you can drag and drop the contents of your uploads folder (ie 2008, 2009, 2010, 2011 + subfolders) into the uploads folder. There should be nothing in it except an empty folder (because you deleted that file in step 5), so it's fine to overwrite if it warns you.

  7. The only remaining step is to transfer your plugins. You can do it via FTP, although it's probably faster to add them directly through the Wordpress admin via "add plugin" and search + install.

  8. Oh yeah, now go to permalink settings and click "default", update, then choose whatever you want-- you need to refresh permalinks to.

That's foolproof... but you have to be somewhat familiar/confident using PHP myadmin. Although I've founds some widgets do not transfer via this method, so you may have to drag and drop some widgets again (appearance -> widgets) after the transfer.

For clarification on step 1 and step 3, see the diagrams here: http://webdesignerwall.com/tutorials/exporting-and-importing-wordpress ... but the rest of that WDW tutorial is guaranteed to give you problems at somepoint.

查看更多
劳资没心,怎么记你
4楼-- · 2020-04-28 10:09

As mentioned in the comments, you will need to browse to the Settings->General page and update your site URL and wordpress URL.

If you can't get to the Settings page because you get redirected to your local site (this has happened to me before), you may have to edit the values in mysql directly, which isn't too bad, really.

The settings are located in the wp_options table under the option_name "siteurl" and "home". If you need more help with that, post a comment.

查看更多
够拽才男人
5楼-- · 2020-04-28 10:20

You may need to refresh your permalinks: see step 5 below. Official documentation on this subject may clear some things up as well.


Steps to move a local WordPress install to a live site

This is my method, and it has worked every time. Assume local WP install is at http://localhost/wordpress/ with WP database named wordpress and live WP install is at http://livesite.com/ with WP database named livesite:

  1. Create a backup of local WP database -
    • navigate to http://localhost/phpmyadmin
    • select database wordpress from side menu
    • click EXPORT
    • check the box for Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement
    • click GO - it should download a file called wordpress.sql
  2. Download a database for the live site -
    • sign in + navigate to http://localhost/wordpress/wp-admin/options-general.php
    • enter the live site values for WordPress Address (URL) and Site Address (URL)
    • click SAVE CHANGES - this will break your local WP installation: that's why we made the backup
    • repeat step 1 [Create a backup of local WP database] - include all substeps
    • rename this newly downloaded file from wordpress.sql to livesite.sql
  3. Prepare WP files for live site
    • upload WP file structure to http://livesite.com/
    • edit /wp-config.php to have live database name, username and password
  4. Import live WP database - if you haven't created the livesite database yet, do so now
    • navigate to http://livesite.com/phpmyadmin or equivalent
    • select database livesite from side menu
    • click IMPORT
    • choose local file livesite.sql from step 2
    • click GO - it should successfully import the livesite database
  5. Refresh live site permalinks - your permalinks are set correctly but not updated to reflect the new domain, so get WP to update them
  6. Revert local installation - this can really be done at any point after step 2.
    • Follow step 4 from http://localhost/phpmyadmin using the backup created in step 1. This is the only way to fix the local install because we changed the domain in step 2 and we can't even get back to the settings page.

NOTES

  • using WP 3.3.1
  • using phpMyAdmin 3.4.8
查看更多
登录 后发表回答