Migrating Wordpress Site from subdirectory to root. Problems! - wordpress

I have a new version of my website that I'm ready to golive. This new version is in the /info directory off my root domain...
So my current website resolves to site.com
And my wordpress version which will replace it is at site.com/info
What do I need to do in order to make the switch?
I followed network solutions tech support on the initial attempt, which was to change the "Directory" assignment of www.site.com and site.com so that they both point to htdocs/info.
That worked, however, my site's stylesheet no longer appears to be working, and all my links still have the /info path in them. Do I need to simply do a find/replace on mySQL to fix the paths?
UPDATE: I was able to resolve the issues with this simple find/replace functions on wp_options and wp_posts as shown below...
UPDATE wp_options SET option_value = REPLACE (
option_value,
'http://www.site.com/info',
'http://www.site.com')
UPDATE wp_posts SET post_content = REPLACE (
post_content,
'http://www.site.com/info',
'http://www.site.com')
UPDATE wp_posts SET guid = REPLACE (
guid,
'http://www.site.com/info',
'http://www.site.com')
Finally, to resolve remaining 404 issues, I had to go to Dashboard > Settings > Permalinks and just click "Save Changes" in order to get the permalinks to resolve correctly

Did you follow this: Moving WordPress « WordPress Codex?
If you can't back up, you will have to go to the wp_options table databse with phpmyadmin and fix a few paths, but it can be done without an MySql query. Pages have their URL in the wp_posts table.
Are any URLs hardcoded in theme files? It's best to use blog_info functions, i.e. <?php bloginfo('siteurl'); ?> and <?php bloginfo('template_url'); ?> instead: Template Tags/bloginfo « WordPress Codex
And this might be helpful: Search RegEx allows search and replace with Grep through all posts and pages.

Related

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

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

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.

Removing URL from Wordpress Database

So I'm trying to clean up my development environment for my wordpress-based site. In the production site Wordpress database, there are thousands and thousands of references to the specific site URL.
For example, all of my permalinks have the full address. All of the images are referenced by their full address. All of the redirects are listed by their full address.
To clone my production database on a dev server, I have to:
Mysqldump the whole wordpress database into an sql file.
Search and replace all of the text for the production server domain name and replace with my dev server IP
Import the modified sql file into my dev db.
I'm clearly not doing something right.....
Suggestions on how I can get back on the right track?
Use this ( change tables prefix and domains at will ) :
/**
To update WordPress options with the new blog location, use the following SQL command:
**/
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';
/**
After that you will need to fix URLs of the WordPress posts and pages, which translated from post slug, and stored in database wp_posts table as guid field. The URL values in this field are stored as abolute URLs instead of relative URLs, so it needs to be changed with the following SQL query:
**/
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://www.new-domain.com');
/**
If you have linked internally within blog posts or pages with absolute URLs, these links will point to wrong locations after you move the blog location. Use the following SQL commands to fix all internal links to own blog in all WordPress posts and pages:
**/
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.old-domain.com', 'http://www.new-domain.com');
The last thing to do ( and only depends on your WP DB version ) is to verify in wp_options that home_urland blog_url have been replaced correctly .
Make sure the wp-config data is correct, ( including prefix ) and you are done .
I am doing this procedure at least 3 times a week in the last 3 years .. :-)
I've had the same problem, but got around it with a simple bash script:
#!/bin/sh
mysql -u«user» -p«password» «db-name» -e "update wp_options set option_value \
='http://dev.example.com' where option_value='http://www.example.com';"
It doesn't change every occurrence of the site's URL in the database, but it allows you to log in without being automatically redirected to the production site.
It works well enough for me anyhow. YMMV
I realize I'm raising this from the dead a little, but as there was no mention of this solution, I thought it important enough to make note of. We've been using this plugin for years with great success.
As opposed to hand-editing or other such pure-sql-based solutions, there exists the Duplicator plugin for Wordpress to allow for easy site migration of an existing site between live and devel and staging servers, though this basically packages up the entire site in a zip archive with an install script that walks you through the process and ensures the migration happens as cleanly as possible, along with follow up testing, logging of the process, etc.

How to change root url in wordpress for existing blog

I did mistake and didnt change my root URL when started work with WordPress, for now I have my blog with about 30 pages and I need change root URL.
My wordpress located:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\wordpress
My blog stays as theme under:
...\htdocs\wordpress\wp-content\themes\myblog
My domain URL:
http://www.myblog.co.il/wordpress/wp-admin
index.php located:
...\htdocs\wordpress\wp-content\themes\myblog\index.php
when I run my main page aka index.php I see http://www.myblog.co.il/wordpress
therefore all generated permalinks look like:
http://www.myblog.co.il/wordpress/?page_id=158 ... .
The main quiestion is: How to change:
http://www.myblog.co.il/wordpress to 'http://www.myblog.co.il/' in order to change automatically all permalinks? a.e. http://www.myblog.co.il/?page_id=158 ...
I saw enough solutions how to do that from start but not when blog is ready.
Please, help me to find proper solution.
Thanks,
Well first of you'll have to configure a virtual host in Apache to match the domain to your htdocs\wordpress folder and not just to \htdocs. You can read more on vhosts in apache here.
Since Wordpress saves all URLS in their absolute form to the database, you'll have to manually fix this by replaceing the URLS in the database. Assuming you're running MySQL and the current URL to your blog is http://www.myblog.co.il/wordpress, you can use these queries:
UPDATE wp_posts SET post_content = REPLACE(post_content, 'http://www.myblog.co.il/wordpress', 'http://www.myblog.co.il');
UPDATE wp_posts SET guid = REPLACE(guid, 'http://www.myblog.co.il/wordpress', 'http://www.myblog.co.il');
UPDATE wp_options SET option_value = 'http://www.myblog.co.il' WHERE option_name = 'home' OR option_name = 'siteurl';
this does not only fix hardcoded links but it also fixes custom links inside the content of your pages and posts.
You tried changing siteurl and home in your options table?
I'm not sure of understanding what you mean, but the page on Moving WordPress might help you.
Assuming nothing else is in root htdocs directory, i.e. if you go to http://www.myblog.co.il/ nothing should show up, update your URL via the admin backend (or via MySQL wp_options table), and move everything inside of the wordpress directory back into the htdocs directory.

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

Resources