简体   繁体   中英

Change Wordpress URL from example.com/wordpress to example.com/blog

It seems like an issue that has been talked about a large number of times, but for some reason, I can't seem to get it to work.

Goal: Change Wordpress site from example.com/wordpress to example.com/blog

Here is what I've tried:

  1. Changed the Wordpress root folder from "wordpress" to "blog"
  2. Then, in phpmyAdmin, changed the siteurl and home url's to example.com/blog

When that did not work, I also went into my theme's functions.php file and added:

update_option('siteurl','http://example.com/blog');
update_option('home','http://example.com/blog');

immediately after the opening

<?php

tag.

Is there something I am missing?

When your domain name or URLs change - ie from http://example.com/blog to http://example.com , or http://example.com to http://example.net - there are additional concerns. The files and database can be moved, however references to the old domain name or location will remain in the database, and that can cause issues with links or theme display.

If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:

1- Only perform a search and replace on the wp_posts table.

2- Use the Search and Replace for WordPress Databases Script to safely change all instances. ( If you are a developer, use this option. It is a one step process as opposed to the 15-step procedure below )

Info taken from http://codex.wordpress.org/Moving_WordPress

Search and Replace for WordPress Databases Script: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

You need to update all URLs in your database too.

Take a look at this script: http://interconnectit.com/products/search-and-replace-for-wordpress-databases/

You could try this plugin: http://wordpress.org/plugins/wp-migrate-db/

From its own description: "Exports your database, does a find and replace on URLs and file paths, then allows you to save it to your computer."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM