(Sorry for the long post as I'm baffled by many aspects of this issue)
I recently converted my WordPress single-site installation to a multisite network. The former site is now the main site of my network. I'm trying to create multiple subsites for my network but I'm running into unusual issues with the URL.
I have the network setup as a subdomain network. I plan to initially create the subsites as
http://subsite1.maindomain.com
http://subsite2.maindomain.com
But then later map these to
http://www.subsite1.com
http://www.subsite2.com
I'm nowhere close to the domain mapping because even the subdomains are not working properly.
The first issue I encounter upon creating a new subsite...After entering all of the details such as site URL, title, and admin email, I am then presented with a blank white page with no error message. I'm not being redirected to the subsite's dashboard or back to a network page. In order to navigate back, I have to enter my network admin URL directly in my browser in order see the new subsite among my list of sites.
The second issue I encounter is though I set the site URL as "http://subsite1.maindomain.com", when I'm viewing any of my subsites and hover over the Dashboard or Visit link, the URL shows that of my main site, http://www.maindomain.com and not of my subsite. I am able to Edit the subsite and change the basic details but I can't get into the dashboard.
It's important to note that the URLs were working for a brief period of time with subsites that I have since deleted. I would create a new subsite and I would be able to get into the dashboard. But suddenly, with no rhyme or reason, the links started linking to the parent and I lost access to the subsites' dashboards. So then I deleted those subsites using the admin network interface and tried creating new ones but I was never again successful.
I've noticed that with the subsites that I created long ago, WordPress created new database tables for them starting with wp_X (where X was the id of the subsite). Now when I inspect my database, I see no tables that represent any subsites. Perhaps those were tables created by plugins because, as I stated, I was once able to get into my subsites and turn plugins on and off.
Also when I was creating those subsites previously, after adding one I would immediately see the subsite listed under the My Sites dropdown. They no longer appear there.
When I go to edit my subsite, even though I originally entered the URL "http://subsite1.maindomain.com", the URL shows as "://subsite.maindomain.com".This doesn't seem right. And when I try to click "Upgrade Network", I am presented with an issue saying one of the subsite URLs is invalid. I believe this is because of the "://" at the beginning of the URL. I've tried removing this from the URL and resaving it, but it always saves with it.
Everything in my database looks fine.
wp_blogs looks like
blog_id
site_id
domain
path
1
1
www.maindomain.com
/
15
1
subsite1.maindomain.com
/
no data in blogs_meta
wp_site has only one record
id
domain
path
1
www.maindomain.com
/
wp_sitemeta contains a few thousand records but the site_id column for all of them is 1. The value for siteurl is https://www.maindomain.com/
wp_config.php
define( 'WP_ALLOW_MULTISITE', true );
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', true);
define( 'DOMAIN_CURRENT_SITE', 'www.maindomain.com' );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
RewriteRule ^(.*\.php)$ $1 [L]
RewriteRule . index.php [L]
I thought maybe the issue could be with SSL or DNS, but the URLs should still link and display the correct link when I hover over the Visit or Dashboard links.
I've deactivated most of my plugins network-wide and really don't want to deactivate any more plugins or my main theme as it will cause my main site to be down until they are activated on the site level. In my experience, reactivating my theme once I deactivated doesn't always honor my previous settings. I don't think the issue is a plugin or theme conflict.
Related
I am fixing an old wordpress site that is not to be updated but maintain the same state. It was created in 2012. Over the years the hosting company updated PHP and Wordpress automatically and broke the site.
I need the site to be in it's 2012 state so that everything works well. I have rolled the Wordpress version back to 3.3.1 and have PHP 5.4 running on the site.
Certain functionalities work again on the site which is good. However, the admin panel doesn't work in so much as the admin menu appears but when you click on the tab it is blank on the right hand side. If you know how to fix that, please let me know. Error logging doesn't appear to produce any leads.
My issue is that in rolling back, permalinks have gone back to their ID routing rather than page name routing. I need them to be page name routing but since the admin menu is broken I will have to create some rewrite rule in functions.php to achieve this.
Can someone inform me what to write on this. I am unfamiliar with rewrite rules.
This should go without saying, but make sure you have a backup before trying this!
I have not tried this myself, and I'm not sure how much has changed since 3.3.1, but this is what I would do:
Locate the permalink_structure entry under the option_name column of the wp_options table.
Modify the option_value to the structure you want to use. For example /%postname%/
To flush the permalinks or rewrite rules from your theme, you need to use the flush_rewrite_rules() function. Add the function to your functions.php file and refresh a page, then comment it out - you only need run it once.
Confirm the .htaccess rewrite rules are in place:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
And hopefully, that should be it!
i've a simple question but i cant find and answer for that:
i have in my site-root folder 3 subdirectory, in the first one i have a wordpress site, in the second and in the third two other sites but only for testing like this:
domain.com/wordpress/
domain.com/test1/
domain.com/test2/
Now i want when the user goes on the site to redirect him on my wordpress site but also when i want to access the other sites i directly put the correct address and go.
Right now i have the code down below but, when i try to connect to other folder he redirect me to the 404 wordpress page. How should i edit it to make it works?
I also want if its possible when i go on wordpress to not show the subdirectory in the url but only the domain:
NOT -> domain.com/wordpress/index.php
BUT -> domain.com/index.php
RewriteEngine On #created by aruba do not touch this file!
RewriteCond %{REQUEST_URI} !(.*)wordpress
RewriteRule ^(.*)$ wordpress/$1 [L]
For some reason, all of my wordpress images stopped displaying. I've tried disabling all plugins, and reverting to twenty-twelve theme, but still nothing.
When I login to the dashboard and go to the Media Library, this is what I see:
But when I click on one of the images, and go to its path, the image URL will load the image.
It almost seems as if Wordpress has disconnected itself from my uploads folder?
Lastly, on my homepage, when I right-click on the broken image link for my logo (that's not displaying), and choose "Open image in new tab", it doesn't actually return the image URL. It returns:
http://127.0.0.1/
Has anyone else come across this before? I have no idea where to begin solving this, as it doesn't seem to be associated with my theme, or my plugins, and my Wordpress core is up to date.
Any help would be much appreciated. Thanks!
The change the the htaccess file that you mentioned in a comment is likely the cause. This is not part of WP Security plugin. Since you have that security plugin installed, you hopefully made a restore point of your htaccess file and should be able to get a good copy back quickly - it's one of the plugin's features.
Details here: https://www.tipsandtricks-hq.com/how-to-restore-the-htaccess-file-when-using-the-all-in-one-wp-security-plugin-5945
If you need to redo the file via FTP instead, here's a list of the most likely htaccess file content, derpending your site's exact needs: http://codex.wordpress.org/htaccess
Probably, it should look like ths:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
It can be a hack, but this generally happens when your wp_options are not correctly configured.
Quick way to solve: Restore a backup to a previous working condition.
If you don't have a backup or want to check other options, try this:
open phpmyadmin in your live server and access the Wordpress database;
Inside the Database, access the table wp_options;
Check the values for the rows 'siteurl' and 'home'.
EDIT: Method 2 - re-create .htaccess
Rename your .htaccess to htaccess_
Go to Wordpress Settings -> Permalinks
Select the default type and Save, this should create a new .htaccess
Open the homepage of website and check if it changed something
Return to Permalink Options and select the way you had it before
I am trying to move a deployed WordPress Multi-Site to a local environment. I backed up the server database and files. In my local environment, I created a new database and imported the backup. I also copied the server files to my local machine.
I did these steps:
I changed wp-config.php and updated it with the new db-name, db-username, db-password and set define('DOMAIN_CURRENT_SITE', 'www.mysitename.com'); to define('DOMAIN_CURRENT_SITE', 'localhost/mysitename');.
I changed option_value in the wp-option database table to point to my local address.
I also deleted these lines from .htaccess:
# Redirect non-www urls to www
RewriteCond %{HTTP_HOST} !^www\.mysitename\.com
RewriteRule (.*) http://www.mysitename.com/$1 [R=301,L]
But when I go to 127.0.0.1/mysitename I get this error: This webpage has a redirect loop.
And when I change define('DOMAIN_CURRENT_SITE', 'localhost/mysitename'); to define('DOMAIN_CURRENT_SITE', 'localhost'); and I go to 127.0.0.1/mysitename address it shows me the phpinfo() page.
How can I fix my problem?
Please explain if I must set something in .htaccess and wp-config.php files.
Thank you so much.
Edit: Recently had to migrate a multi-site once again, and this guide still works fine as of 01/03-2016. The database edits are very figgedy, one mistake and you either get white screen of death or error connecting to database, so pay attention :)
I couldn't figure out of to allow localhost links with protocol (http://) so if you see "(http:)localhost" read it as http:// localhost/. If someone could edit this for me that would be great!
Normal Wordpress migration:
Backup your database from localhost.
Create new database on new server, import the exported database here.
Upload all Wordpress-files to the server.
Edit wp-config.php, changed database name, username and password. Usually below "define('WP_DEBUG'.. I define "WP_HOME" and "WP_SITEURL", these will override Wordpress database settings for path to root.
"DOMAIN_CURRENT_SITE" is used for multisite installations. So if it isn't a multisite, don't use this, if it is a multisite, just use this and not WP_HOME and WP_SITEURL.
define('WP_HOME', 'http://mysitename.com');
define('WP_SITEURL', 'http://mysitename.com');
If you uploaded .htaccess from localhost aswell, delete it from the server.
Visit http://mysitename.com/wp-admin, login and go to permalinks settings and press save to generate a new .htaccess.
And you're done! No need to bother doing database changes. For your localhost installation, just define WP_HOME and WP_SITEURL to localhost instead.
How to migrate multisite:
Multisites in Wordpress is a pain in the ass to migrate, it involves several database changes and even when you made everything correct it seems to only work some of the times without errors. However these are the recommended steps:
Export database, same as above.
Upload new database, same as above.
Add all your Wordpress files, same as above.
Edit your wp-config.php with the new database info, add the following defines:
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', false); // true or false depending if the paths for each multisite is pointed by a subdomain.
define('DOMAIN_CURRENT_SITE', 'localhost'); // localhost is the DOMAIN of the new location, so even if the ABS_PATH is localhost/whatever, you should have localhost here.
define('PATH_CURRENT_SITE', '/');
define('SITE_ID_CURRENT_SITE', 1);
define('BLOG_ID_CURRENT_SITE', 1);
You should have all of these in the wp-config.php of the site you are trying to export, so just copy-paste them from there, and edit DOMAIN_CURRENT_SITE.
Edit your htaccess like this (Rewritebase /path/ should be relative path, ie if your website is located at localhost/mypage it should be "RewriteBase /mypage/"):
# MultiSite
RewriteEngine On
RewriteBase /subfolder-from-localhost/
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
Database edit time! These steps needs to be done for every subsite your multisite has, if I type change table "wp_site", you should replicate it in wp_site1/wp_site2 etc...
In table wp_options: change fields "site_url" and "home" to (http:)localhost/subfolder (no trailing slash).
In table wp_blogs: change "domain" to "localhost", and "path" for every entry for each subsite to /subfolder/ (must have trailing slash)
In table wp_site: change "domain" to "localhost", and "path" to /subfolder/ (must have trailing slash)
In table wp_sitemeta: change "siteurl" to full path ie (http:)localhost/subfolder/ (must have trailing slash)
Now you should atleast have access to your page, if you still get redirection loop or white screen of death, double check the database changes. Now login to admin, and we need to change some hardcoded URLs in the database, I usually do this with a plugin called "Seach and replace", so download and install this plugin, and use it by typing in what it should search for (old url) and what to replace it with (new url).
Search for: http://mysitename.com
Replace with: (http:)localhost
Now hopefully you have a functional migration of the multisite. As I noted I've done this a couple of times, and it almost seems random if everything works or not. I'd say I had success with this approach perhaps 6 out of 8 times.
Edit: Added how to migrate multisite.
This is close but a little different for a multisite that uses subdomains. You are required to edit your host file to show each site url as localhost(LINK):
C:\Windows\System32\drivers\etc
127.0.0.1 localhost
::1 localhost
127.0.0.1 localhost.com
127.0.0.1 subdom1.localhost.com
127.0.0.1 subdom2.localhost.com
etc..
Then, editing the database as stated above worked, ignoring any subdirectory changes beyond the .htaccess mentioned above but leaving the Base as /
# MultiSite
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
In my install, I needed to update some across the headers and footers to get the styles to load.
Thanks to #ninja for pointing me in the right direction!
Ninja's answer helped a lot. Though you can shorten the amount of the steps described in his answer by using wp-cli for database replacements, so you don't need any third party plugins and to edit single database cells manually. wp-cli's search-replace function works amazingly perfect, at least in my experience in case of usual wp sites. But in combination with the steps in ninja's answer it also has worked with multisite in my case. Here is a great description on how to install wp-cli: https://wp-cli.org
To replace a string through out all the sites run:
wp search-replace //oldurl.com //dev.url.test --network
Yes, the url strings are not wrapped with quotes. From my experience this way the replacement works perfect without any issues which might appear using quotes.
To replace strings in a particular site:
wp search-replace //oldurl.com //dev.url.test --url=https://oldurl.com
To see what urls are mapped to the sites:
wp site list --network
Though the db replacements worked well. I had to deactivate multisite in the wp-config.php (by removing all the multisite constant definitions) and all the plugins first and then to reactivate them from network dashboard.
wp-cli search-replace docs:
https://developer.wordpress.org/cli/commands/search-replace/
You can follow the tutorial at this link.Its explained very nicely and is very easy to understand.
PS for step 6 i suggest you use Velvet Blues WordPress plugin
I recently changed my wordpress blog's server and URL. Before, it was located at subdomain.website.com and now it is located at website.com/newurl. I copied over the files and database, and updated the site URL and and website URL successfully. Initially, the site seemed to have been functioning properly. Somewhere along the road, the server started feeding back an infinite redirect loop on blog posts only. I can properly view the blog's homepage, but when I try to access specific blog posts it enters into an infinite redirect loop. If I turn of permalinks, and use the raw url i.e. website.com/newurl/?p=232 it serves the page properly.
Any idea why my permalinks no longer work? I already tried turning off plugins, and it still doesn't work. I also tried resetting the htaccess file with no success. Any advice is much appreciated.
Here is my htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Also, I am not sure it is relevant or not, but the wordpress installation is in a subdirectory of a magento installation.
A few things to check...
Have you updated the table wp_options? - There are two fields in there that need to be updated when migrating a website, the option names are siteurl and home.
Also depending on your server settings, you may have to manually update your .htaccess as updating your permalinks doesnt always update your htaccess, a problem Iv run into before.
One last idea, the ‘AllowOverride FileInfo’ directive may be the problem, the .htaccess needs to override the main httpd.conf configuration file and is unable to do so without this directive. (This fixed a problem I had a while ago when the postname permalinks ect were not working but using the actual URL was)
Goto Settings -> Permalink -> Select (Post name) and Save it. No matter it is already selected just do it once again. Goto your site and Refresh page and check urls again. This is a common issue occurs when you migrate in other ways.
Please don't touch your htaccess file.
I have experienced this kind of stuffs in the past and only shows right after you moved wordpress to either another folder, a new domain, or when you change hosting.
To fix it, please correct your Wordpress Address and Site Address... I usually just addd/remove WWW and/or changes HTTPS to HTTP and vice versa
In the end the problem was a plugin titled "WP No Category Base" that was causing the redirect loop. Once I disabled it my website was functioning properly again.
Next time you want to move a WordPress site, you can consider using a WordPress plugin to handle the job for you.
There is several plugins that can do this for you.
Check this one : Golive
GoLive Features:
Automatically Export the Database from Source Server
Transfering the files via FTP automatically
Auto-import Database in Remote/destination server.
Update .Htaccess properly
Update wp-config.php file on destination server with the new credentials.
Replace the URLs in Database (Posts, Pages, Menus…), and keep auto-update serialized objects too.