Wordpress - plugins making HTTP requests to the wrong domain - php

Back story- I have a site up and running fine with up-to-date wordpress & woocommerce. The owner wanted to re-do all of the products & to get a new domain name; since the old site is working fine & he has customers placing orders daily, I made a copy of the website using godaddy's installatron & assigned it a subdomain name. Everything was working fine, i thought.
While installing new plugins (Woocommerce, WP All Import, etc.) I am noticing that all the plugins' HTTP requests are being made to the old domain name. The old site is still live so many requests actually still make it just fine, but new plugins aren't working because they are trying to get JS files from the old domain (not the new one).
I've tried setting the WP_CONTENT_URL to the current domain explicitly but it doesn't change the request's location.
Any ideas of issues that could have arisen from the site transfer or the hosting? I'm currently running a grep on the WP files for the old domain name but it's gonna take a while.

Before you begin with this, make sure that you have a backup of your database just in case.
If you have access to the SSH of the Wordpress files, you may use WP CLI. Try running the command below to check if there are replacements:
wp search-replace 'old_url' 'new_url' --dryrun
If there are replacements, that means that you can change the old_url to the new url. Just remove --dryrun to proceed with the changes.

Ended up figuring it out-when I said I had set the WP_CONTENT_URL, I was doing so at the end of the wp-config file, after constants had already been defined. Moving it up before the following line fixed everything:
if ( !defined('ABSPATH') )
define('ABSPATH', dirname(__FILE__) . '/')

Related

Issue accessing local hosted Wordpress site (redirects+other nonsense)

I have ran into quite the issue.
I have been developing a website hosted locally with MAMP. I always used localhost:90/wordpress/ to access the website and it was worked up till today. A few hours ago, I began the process of moving the website from local server to an actual domain. Unfortunately, I wasn't checking URLs and ended up changing some information and working on localhost myPHPadmin panel as opposed to the domain myPHPadmin panel. Long story short, I changed so much before I realized my mistake, then proceed to change even more, and now I am lost and don't know what to do. At this point, I am just trying to get access to my local hosted website so I can start over again.
The issue:
Everytime I goto localhost:90/wordpress, Chrome redirects me to localhost/wordpress and my website doesn't show, it says that the website can't be shown.
I have tried going into my local hosted myPHPadmin panel and changing siteurl and home to both say localhost, but no luck. Interestingly, when I change both to wordpress, it shows an unformatted version of my homepage (Kinda like just straight HTML), with limited images, however if I click any links then it brings me to wordpress/about and it doesn't exist. If I change it to just localhost:90, it shows my unformatted wordpress Page not found page. Can't access wp-admin with any of them.
I have tried using a replace tool recommended in another thread, but searching for localhost and replacing with localhost:90 yielded no results for me. I have also double checked the .htaccess folder and it is correct. I have cleared cookies/cache and still nothing. I am desperate.
Any help is much appreciated.
I am not sure what the issue is here so I am going to shoot in the dark here and hopefully one of these methods will get you out of your predicament. Since you say that you have reverted all the changes you made and still your website is inaccessible, even wp-admin.
You can try doing the following:
Change the siteurl and homeurl links in your PHPmyadmin to localhost:90/wordpress or whatever it was before when your site was running and functional.
In your Wordpress root folder, there is a file called wp-config.php. Open that file and find:
* #package WordPress
*/
Add after:
define('WP_HOME','localhost:90/wordpress');
define('WP_SITEURL','localhost:90/wordpress');
You will replace all localhost:90/wordpress if need be by which I have written in my codes to what the link was before; when the site was functional.
Check the file thoroughly and through Find/Replace function of your favourite text editor for no duplicate entries.
Now try accessing wp-admin. If you still cannot access your wp-admin, take a backup of your current wp-admin folder.
From a fresh Wordpress of the same version as yours, copy the wp-admin folder and replace it with your current wp-admin folder. Now try to access wp-admin again.
If you are able to access it and login, refresh your Permalinks. See if your site is accessbile again after doing these steps.
Update:
Since none of those steps worked for you, try doing the following:
Delete all the Wordpress core files from your localhost:90/wordpress EXCEPT wp-config.php and your wp-content folder.
Now from a fresh Wordpress folder, copy the files and folders EXCEPT wp-config.php file and wp-content folder. Paste them in your localhost:90/wordpress folder.
Try accessing your website now.
Update 2:
Try uploading your Wordpress to your online server and change the values of siteurl and homeurl in your wp-config.php file. We defined the localhost addresses in the file, now you will update those with your domain details.
Take a fresh backup of your database from your localhost and import it into a new database in your online server. Update the homeurl and siteurl in your newly imported database.
Update your wp-config.php with the new database name and username and password of the account you have given all privilages to access the database.
Try accessing wp-admin now.
If successful, update your Permalinks and then try accessing your website.
This will tell us if your localhost is faulty.

WP-Admin redirects to old URL (after editing config.php)

I am trying to get a client's WordPress site copied over to my company's server to use as a development site. I've ran into an issue when trying to log into the site's administrator panel; it redirects us to the existing site's URL instead (ending up as [OLD SITE]/[NEW URL]/wp-admin). Additionally, trying to go to any page other than the homepage gets a 404.
I've tried editing the wp-config and defining the WP_HOME and WP_SITEURL there, with no success. In a previous attempt we used a backup tool that was meant to replace references to the old URL with the new URL, and on another we ran queries and checked through wp-options in the database to be sure that we caught all of the old references. Still redirects to the old site.
We've tried restoring from two backups, Akeeba and BackUpWordPress. Our current attempt is a copy we've downloaded directly and then uploaded (with an imported SQL backup).
Another odd thing I've noted is that changing one of the URLs in the database causes more issues. Mainly, if I update the URL of 'wordpress-https_ssl_host' in the wp-options table, the theme breaks. Not sure where to go with this from here.
I'm always succesfully using the following script : search & replace:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
in order to update a wordpress site url.
Just copy the provided code in a directory under your site, then launch the provided index.php in a browser: the database infos should be automatically determined. Then specify the old and new urls and click on "Run" !
Don't forget to remove the created directory afterwards.
For solving this issue you have to change siteurl in database wp_options table
option_name = siteurl where
option_value = YOUR OLD SITE URL
change your old site url and update it with your local developement site URL
Hope this will help you..
We found the problem; as it turns out it was nothing to do with anything from the default WordPress files. The client was using an extension called WordPress HTTPS, and apparently that was causing a conflict somewhere. We renamed the extension's folder to disable it and everything ran fine. I imagine it was overriding what we were setting in wp-config.

Migrating Wordpress to a site with a subdirectory

I've migrated many Wordpress sites before, but now I'm having an issue I just can't seem to solve. Some, but not all of the links are not loading properly.
I'm migrating from local.dev to example.com/test.
In my database options, I have both options set to example.com/test.
I doubled checked the options in the WP backend, and they're example.com/test.
I've updated my permalinks.
All of the pages work, all of the links work, but a few references to images, etc do not - they're loading example.com/ instead of example.com/test.
I think it might have to do with the .htaccess file, because I can't update it from the FTP side. If I delete it and update permalinks, no .htaccess file is created. I don't have access to any server side overrides, only the files.
In my MAMP vhosts, I have SymLinks Override set to All, but I can't edit anything like that on the live host.
The links that aren't working are along the lines of $image = get_post_meta(37 ,'_my_meta',TRUE)['img']; which should return
http://www.example.com/test/wp-content/uploads/image.jpg
but instead returns
http://www.example.com/wp-content/uploads/image.jpg.
Using bloginfo('wpurl'); returns http://www.example.com/test, and all similar ones return properly (site_url();, 'template_directory', etc.
In the end, the site is going to go on http://www.example.com without the subdirectory anyway, but I'm sure I have to get it to work properly to prevent future errors.
I also updated to the newest version of Wordpress at some point, not sure if that could cause any issues.
I believe the issue deals with media and links placed in content items.
I use to do some manual SQL queries to fix this but now I run this plug-in https://wordpress.org/plugins/automatic-domain-changer/
The plug-in will go through all the content and make the needed changes.
The links that aren't working are along the lines of $image => get_post_meta(37 ,'_my_meta',TRUE)['img']; which should return
http://www.example.com/test/wp-content/uploads/image.jpg
this meta information is stored in the DB. then to make the migration you have to change all the old URL in the DB before to import it in the new place

Wordpress White Screen of Death

One of my client's site was taken down by hosting as it was sending spam, the site was working fine before it was taken down by hosting, I downloaded the wp-content folder from Cpanel and full dump of database. When I run the site at localhost, it shows the blank page on all directories. When I use the dumped database, it goes blank but when i change it to fresh WP database, the sites looks fine, so it means there is some problem or mis configuration on database? I started debugging manually and found that the file wp-blog-header.php is not getting this file
require_once( ABSPATH . WPINC . '/template-loader.php' );
Because I added echo "Oh God why?"; in template-loader.php and it was not showing the result while with the fresh integrated database, it shows the result.
Can someone please give suggestion that what could be the problem in database?
Your live WP site and your local one will (should) use two separate databases.
In your local phpMyAdmin, make sure you've imported the exported database from the live site.
In your wp-options table, change siteurl to http://localhost/yourpath/toWP.
This should be pointing to your actual
Wordpress folder.
Locate the wp-config.php in your actual WP folder, and make sure the WP_HOME, WP_SITEURL, DB_NAME, DB_USER, DB_PASSWORD, and DP_HOST
All of this has to match up to your local setup, otherwise it will fail (WSOD).
If this doesn't work, it's possible the person that set it up changed some things to make it hard to maintain without him/her. I've seen it done. Personally, I detest WP for things other than blogs. It has a lot of security problems, constantly needs updates, and allows people that really shouldn't be doing web design to toss something together with templates and call it "professional". Good luck!
You are basically changing the domain of your WordPress installation from www.example.com (the original domain) to www.example.local (your localhost).
I usually use this procedure to move WP from a domain to local:
Download from WordPress site the corresponding version of WP and install it on local.
Overwrite the new db with your backup
Change wp-config.php to point to the backup db (only if config changed, i.e. table prefix)
Follow one of the many guides to move WP to a new domain. Example 1, Example 2 and change the db fields to your local domain (www.example.local).
Restart your local apache
It should now be ok to login and regenerate permalinks.

Presta Shop Switching Domain Issue

I have a website made on Presta Shop CMS. I had it on my trial server. The installation and everything. It works and runs fine. I then copied (using FTP) every file from my trial server to the main domain. I did not install it on the main domain (bought from network solutions), but copied everything there.
The issue is when i hit the main domain, it somewhat redirects me back to the trial server. I have checked and changed many of the default values. and many values in the database. But still havent had luck. Also made changes in the .htaccess file, still without any luck.
I do not want to go through the installation process again on my main domain.
You can check the site (main domain :- www.myworld-myhome.com, it will redirect you to hrm.com/esol/ )
As you can read here, the prestashop domain name is stored in the ps_configuration table.
So, to solve your problem, you should run this SQL query:
update ps_configuration
set value='www.myworld-myhome.com'
where name='PS_SHOP_DOMAIN';
You should also edit your config/settings.inc.php file and change:
define('__PS_BASE_URI__', '/esol/');
To:
define('__PS_BASE_URI__', '/');

Categories