How to map or copy a wordpress site to a subfolder in an existing site's route? - wordpress

I have a Wordpress blog (blog.xxx.com). I have a nuxt personal website yyy.com which is hosted on aws.
Now I wish to map or migrate the Wordpress blog (blog.xxx.com) to my personal site (yyy.com/blog).
How can we achieve this? yyy.com should show my personal site and yyy.com/blog should take you to my blog.
Can I configure this in Wordpress or what else can I do to achieve this?
I tried mapping it to a new domain, but I’m not sure how to map to a particular route and get it to work when I visit (yyy.com/blog/{blog-name}.

Yes, you can set up a WP site in a subfolder of your main website. I don't recommend doing it manually, too much can go wrong. Use a plugin such as Duplicator - it's so simple to use:
Install it on the site to copy and build a package - this packages your entire website into a single zip file
Copy this ZIP file and installer.php to the the hosting new location on your hosting (e.g. yyy.com/blog)
Create a new empty database
Run the installer wizard and make sure the URL in the new settings is https://www.yyy.com/blog
That's it!
You can have the entire site set up & running perfectly in just minutes! it will even set up .htaccess correctly.
No more setting up the database, changing urls in the database, 404 errors, broken links, broken images, etc. Moving a Wordpress site manually can be tricky and you can waste hours trying to fix the issues. Even agencies use a plugin to avoid the problems.

If I understood your question correctly, you want to move your WordPress installation from blog.xxx.com to yyy.com/blog, right?
There is an official guide for this provided by WordPress: https://wordpress.org/support/article/moving-wordpress/
After you have changed the siteurl and home fields in table wp_options of your database to yyy.com/blog, you can use a plugin like Better Search Replace (https://wordpress.org/plugins/better-search-replace/) that scans your WordPress database and replaces every URL of posts etc. with the new URL of your blog.
In addition, in case of an Apache webserver you need to take care of the .htaccess file and change the RewriteBase to /blog (assuming that it was / before).
Some special plugins (for caching etc.) need some special treatment, but often clearing the cache solves the problem.

Well despite Johannes is perfectly clear for me, i'll try to simplify.
Clone WordPress files from blog.xxx.com to yyy.com/blog directory. (not sure how your server is configured, but probably you'll be able to access it.)
Clone Database to new server.
Run sql replace queries:
UPDATE wp_options SET option_value = replace(option_value, 'https://blog.xxx.com', 'https://yyy.com/blog') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'https://blog.xxx.com','https://yyy.com/blog');
UPDATE wp_posts SET post_content = replace(post_content, 'https://blog.xxx.com', 'https://yyy.com/blog');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'https://blog.xxx.com','https://yyy.com/blog');
update your wp-config.php to match your new database.
login to yyy.com/blog/wp-admin
go to settings and update your permalinks

Related

Moved website location: Loading failed for the <script>

Building a Wordpress site locally, I've moved the website's location from localhost/company to the root (so localhost). I've gone into the settings in phpMyAdmin and changed the siteurl and home to 'http://localhost'.
Initially the site loads almost correctly (missing some images, elements etc). I presume these missing things are down to me not going changing the links using MySQL or the Velvet Blues Plugin.
However, when I refresh the entire website structure fails. Only a few elements actually load. If I inspect, I see the same error over and over.
Loading failed for the with source "http://localhost/company/wp-content/themes/grandtour/js/jquery-3.3.1.min.js".
This error continues referencing just about any JS file within /wp-content/ or /wp-includes/.
I'm unsure why it's still looking into /company/ despite me changing the phpMyAdmin settings.
Edit: A large amount of the JS files are being linked to like below:
<script type="text/javascript"
src="<?php bloginfo("template_url"); ?>/js/jquery-3.3.1.min.js"></script>
So it would appear that 'template_url' is still seen as localhost/company. Should this have changed when I changed 'siteurl' and 'home'?
Edit 2: The problem is now also occurring when I upload the site to a live domain, so it's not a localhost issue.
There are 2 thing you need to do when changing your website domain name or URL.
The first thing you would want to double check is that your SQL entries reflect the correct new URL. The SQL statement below will adjust the URL's inside wp_options, wp_posts and wp_postmeta.
UPDATE wp_options SET option_value = replace(option_value, 'http://oldsite-url.com', 'http://newsite-url.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = REPLACE (guid, 'http://oldsite-url.com', 'http://newsite-url.com');
UPDATE wp_posts SET post_content = REPLACE (post_content, 'http://oldsite-url.com', 'http://newsite-url.com');
UPDATE wp_postmeta SET meta_value = REPLACE (meta_value, 'http://oldsite-url.com','http://newsite-url.com');
The next thing you want to adjust is your .htaccess file. The quickest way to do this is to go to Settings -> Permalinks and click save.
This will regenerate your .htaccess file, assuming that your new server has got the mod_rewrite rules enabled (most do). As mentioned in your comments, deleting the .htaccess is also a potential fix (but keep a backup just in case).
it is always better to keep your site with-in the directory instead moving to localhost which is primary location of your websites.
Primary location means where you can setup multiple websites in a directory.
If you are curious about URL structure you should look for Virtual Host.
Here is the setup guide on cloudways.com
So, Keep your site in htdocs folder if you are using XAMPP. and setup VHOST for pretty URL's.
after setup the V-HOST URL would be like http://yoursite.html
Everything will work perfectly without any error.
In the end, to solve the issue, I used this search and replace tool for WP databases. https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
I'd updated the links using MySQL and also attempted using the Velvet Blues plugin, which is what I usually use without issue. However, this tool was able to find an additional 8 entries, which when updates, solved the issue.

Error Moving WordPress

I'm in the process of trying to move a WordPress site from "example.com/wordpress" to "newsite.com" and I've run into some considerable trouble.
I made a backup of the database and put a copy of all of the WP files onto the new host. I then tried to change the URL, but got a bunch of errors on the new page. I tried to revert back to the old site in the hopes getting everything in order again, but now everything redirects to the "new" site. My wp-config and database settings are all the same as they once were since I never deleted them off the old site. I've since deleted the files from the new site. The page is still redirecting and I can't access the dashboard login.
I'm completely at a loss right now, so I could really use some expert opinion. Thanks for any help that leads to a solution.
Old Site Link
If you have access to phpmyadmin or any interface for your database you can go into the wp_options table and update rows 1 and 36. As jogesh_pi mentioned, the base url of your site is stored there, so you will need to update the database with your new path.
You can run this query in phpmyadmin and it will do it for you. Obviously replace the newsite url with your own.
UPDATE wp_options SET option_value = 'http://www.newsite.com' WHERE option_name = 'siteurl' OR option_name = 'home'
You need to run a database query that updates all instances of your old URL with your new URL. The process is explained in detail in the Wordpress Codex.
I like to use this very useful PHP script for running the database update automatically as it takes into account serialized strings which in certain cases can break widgets or plugins if they are not addressed.
I always run into this issue, I use this plugin now to transfer wordpress sites: http://wordpress.org/plugins/duplicator/
But heres a quick fix:
Login to phpmyadmin, go to your database
Go to wp_options
Change these two options to your new url where my url's are the old ones:
If your wp-content folder is of the old site contents, it should pick up. But if your images dont show, use a URL changer plugin like this one: http://wordpress.org/plugins/velvet-blues-update-urls/
it's just a simple query that helps you to transfer your wordpress site from old to new.
update wp_options set
`option_value` = replace(`option_value`, 'example.com/wordpress', 'newsite.com');
beside this make sure about the file permissions and the database is same that you have used in the old site.

wordpress on localhost linked to live site

A few months ago I put together a site using Wordpress for a friend, I developed it on localhost and exported it to his live site paulscreen.com
I have recently been asked to do the same for someone else and I set about it the same way, my problem is at some point I accessed paulscreen.com (I don't know how or when) and in doing so I have set his site to viciousnature.co.uk, I assume by changing the home url in the options panel in the admin area.
Now when I try to access the admin area for the first site, I get redirected to the second. I have been going through the wordpress code, but only have limited coding knowledge and cant find how to fix the mess up.
Where do I find the option to edit the home url, without using the admin area?
See Changing The Site URL « WordPress Codex for different methods to recover. You don't necessarily have to be able to get into WordPress administration backend.
The easiest quick fix is add these define URL directives in wp-config.php:
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
with the URL of the new domain, and those will override the URL settings in the database and the old domain. You're hardcoding the URLs and you won't be able to edit them on the General settings page anymore after using this method, but that will get you back into the site.
If you need to change domains when moving a site and database to a new domain, you need to use queries in phpmyadmin to change all URLs in the database, i.e. those site URLs, as well as in theme options, in post content, etc.
UPDATE wp_options SET option_value = replace(option_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.olddomain.com/','http://www.newdomain.com/');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.olddomain.com/', 'http://www.newdomain.com/');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://www.olddomain.com/', 'http://www.newdomain.com/');
Important Update 2/20/2017:
When moving a site and a database to a new URL or domain, it's now best to use this - interconnectit.com WordPress Serialized PHP Search Replace Tool - rather than queries directly in PHPMyAdmin that I posted above. The Interconnectit tool will correctly handle serialized data in the database, such as used by Wordpress themes and plugins; using those queries in PHPMyAdmin will break such data, such as used for theme options, widget settings, etc, and you will have to reset all those options afterward, which can be a mess.
Whoops. Make the change to the database directly through phpmyadmin. Login into the panel for the server and look in the database table wp_options (assuming you never changed the default prefix, if you did it'll be yourprefix_options).
It's the siteurl option, if you browse the table it's right at the top. If you don't have panel access anymore for whatever reason, and only have FTP then you can upload adminer.php and use that to change the siteurl option from your browser.
I would prefer to go with the wordpress rules :)
Because you never know what wordpress does behind the scene, I wouldn't hack wordpress database.
Simply you update your vhosts and put the live domain to point to your local ip address. After that wordpress still redirects you to the live url but this time you see the local project.
Login to the admin panel. Go to settings and change the WordPress Address (URL) and Site Address (URL) with your local url. Save the changes. Edit the vhosts file and remove the live domain.
Now you can access the local project putting the local url.
Note: when you want to import the local database into the live server, don't forget to do the same visa versa.

Wordpress home page shows a 404 error

I have a wordpress site in one domain (say domain1)
Now i created a wordpress in another domain (say domain2)
and put the theme from domain1.
And updated the DB with the Db from domain1
Now while i take new wordpress site's(ie wordpress in domain2) home page ,it shows a 404 error
Will any one please help
You can't just put the wordpress tables from one domain into the DB of another domain. There are some configuration values saved on the DB that need to be updated with the name of the new domain.
That could be the source of the 404 error. To solve this, open the SQL or CVS DB file in a text editor and search/replace the old domain name for the new one.
You have to follow certain steps to 1) move WordPress within a host, and 2) move Wordpress to a different domain.
This mostly involves changing URLs in the database either by moving Wordpress in a certain way so that the database gets updated, or updating the database after the fact. And updating permalinks in .htaccess, too.
See Moving WordPress « WordPress Codex and How to Move WordPress Blog to New Domain or Location » My Digital Life.
None of these steps will change URLs hardcoded in theme files, like header.php or the style sheet if you edited those while building a theme.
SQL queries to change URLs in the database via phpmyadmin.
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
If the files are there, under the domain. First, try domain2.com/index.php. If it works, you must add an .htaccess file to your directory with the enrty
DirectoryIndex index.php
If it is not there, the domain points to different directory. Then it is not a wordpress related issue, only server config which can be resolved by your host company.
Trouble is, a 404 error can come from so many places. Did you just register the new domain? If so, it might just take a while for the DNS changes to propogate.
You will probably also have to change the configuration settings for the new domain's wordpress site. You can find detailed instructions on how to change it (wp-config.php) here http://codex.wordpress.org/Editing_wp-config.php

WordPress - moving from one host to another

I am trying to move a WordPress installation from one server to another one, including all of the SQL data, and the file-system data (photos,template files).
I just have a problem changing the URLs in the database, since I need to replace the new URL with the old one.
I would love to have some suggestions about how can I replace the URLs (maybe there's a rplace statement in SQL?)
Thanks in advance.
Edit 5/16/2015
It's much better to use interconnectit.com WordPress Serialized PHP Search Replace Tool to find/replace URLs in the database and to correctly deserialize/reserialize that data. Doing a find/replace in a text dump or with the UPDATE queries below will break serialized data.
Several easy ways: How to Move WordPress Blog to New Domain or Location » My Digital Life:
UPDATE wp_options SET option_value = replace(option_value,
'http://www.old-domain.com', 'http://www.new-domain.com')
WHERE option_name = 'home' OR option_name = 'siteurl';
and others:
How to Find and Replace Text in WordPress MySQL Database using SQL When Changing Domains » My Digital Life
Search RegEx « WordPress Plugins for grepping through posts and pages as a WP plugin-based way to replace image and other URLs in posts and pages.
And there's Moving WordPress « WordPress Codex.
One thing to be aware of is that WordPress stores some of it's data using serialised arrays (some plugins in particular, such as cforms, do this).
In instances where the site URL data may be serialised, simply updating the site URL text can change the length of data in the serialised string, corrupting the data and breaking things.
Interconnectit have a php script that takes serialisation into account when doing a search replace in the WordPress database. Github repo of the script here.
I have used this script in numerous WordPress migrations and it has been a lifesaver for me.
You could simply dump the mySQL in a flat file and open it up in your favorite editor. Than do a find and replace for fully qualified domain name if you are literally change domains. That should take care of WordPress specific URL settings as well, so all your links in pages, posts, sidebars etc. will work. Also be sure to change the local path's recorded in the DB to reflect what the new ones will be as well.
Once your done import the mySQL file in to the new DB and have at it. If something when wrong in transit than you'll definitely know. :)
There is indeed a REPLACE() function in MySQL, but I would recommend doing what hsatterwhite suggests and editing the whole MySQL dump as a flat file before re-importing, not least because the REPLACE() function is case sensitive.
This is a really straight forwarded procedure with no frills but extremely detailed for newbies
Make a full wordpress backup from your local server/host using cpanel. (wp + db)
download the backup1.tar.gz generated
Install a new wp site (default theme) on the target host. Same release, please!
warning: If they are different, leverage both releases.
Make a full wordpress backup from your target host using cPanel. (wp + db)
download the backup2.tar.gz generated
Additionally backup (export) wp-admin and wp-users target mysql backups; save them for future use ahead.
enter target host cPanel > file Manager > enter wp diretory > clear all files
upload local host wp backup1.tar.gz files to target host wp directory > extract files
copy wp-config.php file from backup2.tar.gz file
paste overriding wp-config.php file on target host wp directory
enter target host > cpanel > phpmyAdmin > find mySQL BD name of your target wp host and drop all tables.
restore (import) local wp using backup1.tar.gz softsql.sql file to mySQL db on target host
drop wp-admin and wp-users tables after restore. Restore (import) wp-admin and wp-users you saved before. This will guarantee target wp authentication when entering target host wp administrative tasks.
test target host wp url
The wp-config.php copy/paste is to restore target host wp and
mySQL original authentications.
Test target wp at /wp-admin mode.
that's it! Enjoy.
I think the guy is talking about hard links in his page/ post content. You need to apply #markratledge MySQL replace function link this...
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
This will replace all the links in you post/ page content...

Resources