Wordpress website cannot be found after accidentally changing site URL - wordpress

I changed my Wordpress website site URL prematurely and now it tells me Not found The Requested URL was not found on this server. I've been struggling with this and trying to find a fix but everything I've done has not fixed it. I've gone into the config file to update the URL, define the URL, you name it, I've done it. So I'm pretty desperate at this point and any help would be appreciated.
P.s I'm also running the server off of a Digital Ocean droplet. So I haven't been able to access the DB through MyPhpAdmin.
Thank you!

To change the WordPress site URL you need to do it manually as you can’t do it from your WordPress admin panel. There are two ways to do that:
Method 1 - Change WordPress site URL by editing wp-config.php file. This is the easiest way;
Add the following code to the end of wp-config.php file and save the file.
define('WP_SITEURL', 'http://www.example.com');
define('WP_HOME', ' http://www.example.com');
*Change www.example.com with your site domain.
Method 2 -
Please try to change the URL from PHP MY ADMIN > select your database > goto wp_options and change the URL
Using FTP/ SFTP , or your web-host’s cPanel or whatever file management application your host provides, access phpMyAdmin on your host, then find your DB, there check the wp_options Table (Note: The table prefix of wp_ may be different if you changed it when installing), and make sure site URL field and home field are correct.

I found the fix!!
When the site URL changed so did the root directory. The root directory added another folder to the path. So it looked something like this var/www/html.old/html.
Apache was still trying to access the site through var/www/html.
So I adjusted the file path and boom! Apache was able to make the connection and the website is now showing.
To get to the apache folder it was /etc/apache2/site-available/. I was then able to nano into the 000-default.conf file and adjust the file path through there.

Related

Changing URL Wordpress- still not working despite checking/editing database

As much as may sound like a broken record - I changed the URLs on my WP site, and now I get a 404.
What I wanted to do:
Change site URL from www.SiteA.com to www.SiteB.com
All WP files were at the time in another directory in the same hosting account. I needed them in the root directory, accessible by www.SiteB.com
What I did:
Backed up locally and remotely - Database and files.
Edited URL's through dashboard on WP - got a login error afterward, but seemed to do it anyway.
Moed ALL old site files from root to backup folder.
Moed ALL wordpress files from original directory to root directory.
Then I got a 404 error and was unable to access WP-admin or login through the new or old URL.
What I tried to fix the issue:
Noticed http should be https - changed this in 'options' within phpmyadmin, both at 'siteurl' and in 'home'.
Still 404
Then I tried defining the db_name in the wp-config file.
Still 404
Then I gae up, changed the URL's back using myphpadmin, and moed the filed back to their original directory. Now I can login to WP as usual and eerything is fine.
Why can't I access the site when I moe it into the root directory - I thought I had all the steps right!
Thanks in adance for any help
oh..and apologies, my keyboard is missing a few keys :(
Wordpress stores url/permalinks on database field values as well, changing only the configuration files will not be enough.
I am pretty sure there are other options, on my case i use often perform Wordpress website migrations, and the following tool becomes really handy when search and replacing domains on the database records.
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
Hope it helps.
Jose
This happened to be an SSL issue where the host for our SSL certificate was conflicting with the stylesheet somehow. 0_o

Moving WordPress from subdomain to main domain

I’ve read the WordPress Codex instructions regarding moving WordPress, but none of the information provided seems to apply to my exact situation and I have a couple of questions before I go and break things.
I have a main domain on which my old wordpress site is currently running (e.g - example.com) I wanted to change the layout of the website but at the same time wanted to keep my main site running so made a subdomain (beta.example.com) and created my new wordpress website on this.
Now I want to make my beta website the main website (i.e make beta.example as example.com) and remove the main website, how do I go about that?
I am using cpanel and both my folders are in the public html directory
Thanks in advance.
Step 1: Backup: Always backup the files / database of the site(s) you choose to work with
Step 2: Move files: Delete the contents of example.com's document root and move the contents of blog.example.com to example.com
Step3: Change home/site-url: The daabase mght have other hard coded urls too. So changing the home / site url alone will not be enough and a full database search-replace is needed.
I would not recommend using notepad++ or any text editor to change the website url as it has a great chance to break the layout of the website and I have seen it may times happen. I always use and recommend you to use the Database Search and Replace Script from here
Download the version 2.1.0 to the document root of the website as search.php
Now call the script via your browser (as domain.com/search.php). The script autopopulates the database details. The rest of the instructions there are self explanatory to follow.
Step 4: Finishing up: Check the .htaccess file that there are no redirects to the blog.example or similar redirects. If yes, remove them and replace with the default .htaccess wordpress rules.
That should do it.
Steps are below:-
Make a new folder into your root in Cpanel and move your old domain(example.com) files to the new folder as a backup
Move your subdomain (beta.example.com)folder's files into root in cpanel
rename your ht access file it will automatically created when your WordPress run into the browser.
Into your PHPMyAdmin create new database (like new_database)
Download your subdomain database and open it into editor something (like notpad++)
Into notpad++ press crt+f, from tabs click to replace, into find section put beta.example.com and into replace with section put example.com then save it make sure you do not use HTTP, https or www when performing the replacing task.
Now goto your WordPress directory wp-config file and change your database name with newly created one username and password too.
Visit example.com/wp-admin login there with your login details you were using to login into beta.example.com/wp-admin.
Into deshboard->setting click to permalinks and select %%postname%%
Thanks, I hopes it will work for you as example.com

After moving the destination of my WordPress folder and renaming my project, I can't access wp-admin

I moved the destination of my WordPress folder in Finder and can no longer access wp-admin. I'm running MAMP and it's working, but I cannot access wp-admin and am receiving a 404 Not Found page.
My WordPress folder used to be part of Sites/HackerYou/Week7/WordPress. Now it's just Sites/WordPress. The project I'm working on reminds inside the WordPress folder and it has been renamed.
When I go to localhost:8888, that's where I'm receiving the Page not found notification. This is my WordPress so apologies if I'm not providing enough detail, please let me know if there's anything I can add to help you answer the question.
Edit: I have also changed my database name in phpMyAdmin and the wp-config file to the same name that I've given to my project folder.
Try changing the path to your new directory in phpMyAdmin. Go to MAMP > Tools > phpMyAdmin. Select your database and click on wp_options. You need to change the path to your new directory for the "siteurl" and "home". The "home" option might be on the second page.
If you migrate folder mean, Follow these steps:
1) In your database change homeurl & siteurl
2) After migrate update your permalinks
3) Now also getting problem then open you config file
you can enable debug mode (i.e) define('WP_DEBUG', true);
it will show error statement.

Change WordPress URL folder name to another without redirecting

I'm trying to change my WordPress site's URL (without redirecting) from:
example.com/go/take/
to:
example.com/go/give/
Also, if my wordpress site is located in the /go/ folder, is it possible for me to trim /go/ ?
Thank you.
These are two separate issues.
Regarding the first issue, are you saying that you still want a user
to type in example.com/go/take, but be served the file from
example.com/go/give without changing the url? You can install the
wordpress redirection plugin to do that. You can create a 'pass
through' redirect which will do this.
Here's what you can do to run example.com from a wordpress install
in the go subdirectory:
http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory

Editing .htaccess without FTP access through Wordpress

I have no access to my FTP but I'm able to edit the web through Wordpress. Is there any way I could perhaps generate the .htaccess file through the admin framework? I know there might be a plugin to do that, but bear in mind I have no FTP access and the plugins require it to be installed.
I need the .htaccess file to redirect the user to another site.
I know this might strike you as weird and stupid, but this is due to the company's central decision to keep the site hosted by, I guess, a "friendly" hosting company. There's no way of recovering the login/password for FTP, so this might be the only solution.
Please, try posting constructive comments only, no "contact the hosting company". If I could, I would.
If your hosting company has set up wordpress correctly, then there is no way to do this, because unix permissions should make .htaccess read-only to the owner of the web server.
If the company has not done this, and if you have a way to change the templates, you might have success by creating a template that contains php code to open and write the .htaccess file.
Sample code to be put at the top of the header.php:
echo 'Current dir: ',getcwd(),"<br>\n";
if ($handle=opendir('.')) {
while (($file=readdir($handle))!==false) {
$ok=(is_writable($file) ? "ok" : "can't write");
echo "file '$file': $ok<br>\n";
}
closedir($handle);
}
This is to test you're in the root directory of your wordpress installation. It should give you the current directory, a list of all files in that directory (expect .htaccess, index.php, and various wp-* files), and their writability.
Once you've checked everything is correct, add
file_put_contents('.test', "RewriteEngine On\nRewriteRule ^(.*)$ site.com$1 [R=301,QSA,L]\n");
echo("<code><pre>-------- included file starts here\n");
include(".test");
echo("-------- included file ends here</pre></code>\n");
to the php code. This writes to a test file and includes it so you can check if everything is ok. When you've checked the file contents, replace .test with .htaccess.
WARNING: You should be VERY sure about the content of .htaccess. file_put_contents doesn't append the new string, it overwrites the whole file. Once you've written a bad .htaccess file, you might not be able to ever change it again, because the web server will redirect you to the new site instead of executing the script on the old site.
I am sorry for your situation. What is the hosting company (will keep this in mind if I ever use them). To try to help:
Do you have access to CPanel? Most hosting providers give it out of the box. Cpanel has a file manager.
Research Wordpress file managers (http://wordpress.org/plugins/wp-filemanager/)
How to edit wordpress .htaccess file from hosting Cpanel: If you are currently unable to login in your wordpress dashboard, or facing 500 internal server error. There is 90% possibility that you were editing your .htaccess file from your wordpress dashboard. In this situation you can only fix your wordpress .htaccess file by editing it from cpanel. Editing .htaccess file from wordpress dashboard is little risky with .htaccess editor plugins. If you will implement any wrong code then you might face 500 internal server error and your site might crush. So first you should take a backup of your existing .htaccess file before editing it. If you have a backup of your wordpress .htaccess file then you can upload it through your hosting cpanel also.
https://howtoways.com/how-to-edit-wordpress-htaccess-file-from-hosting-cpanel/

Resources