Implement Multisite in wordpress in sub directories - wordpress

I am trying to implement multisite so that I can add several other blogs.
I added define('WP_ALLOW_MULTISITE', true); line of code in wp-config.php file under define('WPLANG', '');
When I look at the configure network panel I get this message:
"Because your install is not new, the sites in your WordPress network must use sub-domains. The main site in a sub-directory install will need to use a modified permalink structure, potentially breaking existing links."
I want all my blogs to be in sub directories.
Like : http://abcd.com/site1, http://abcd.com/site2, http://abcd.com/site3
What should I do so that I can proceed with installing the multisite option using sub directories?

Hi Try adding the following code in your themes functions.php . It w
add_filter( 'allow_subdirectory_install',
create_function( '', 'return true;' )
);
That’s it. Now reload the Network page and you will see option to choose between sub-domain and sub-directory. Once done remove the code from functions.php.
Source tip credit

To answer your question:
http://codex.wordpress.org/Multisite_Network_Administration#Switching_network_types
But please note that if your site is older than a month, you might have serious conflict issues between pages and sites. Read the directions I provided, and read the cautions. As always, BACK UP YOUR DATABASE AND FILES... including the wp-config.php and .htaccess files :)

Related

How to update get_stylesheet_directory_uri in wordpresss

How do I update get_stylesheet_directory_uri? Transferring a website and I have already updated the url for the site inside wp-config using:
define('WP_HOME','https://somewebsite.com');
define('WP_SITEURL','https://somewebsite.com');
Still when get_stylesheet_directory_uri is called it is using a previous url, any idea on how to force this to update?
Thanks!
Once you change the site URL using those DEFINE statements, you also need to flush the permalink settings. Just go to wp-admin -> Settings -> Permalinks, and save without making any changes. That should force it to use your new values.
If you have access to the site via FTP, then this method will help you quickly get a site back up and running, if you changed those values incorrectly.
FTP to the site, and get a copy of the active theme's functions.php file. You're going to edit it in a simple text editor and upload it back to the site.
Add these two lines to the file.
update_option( 'siteurl', 'http://example.com' );
update_option( 'home', 'http://example.com' );
Use your own URL instead of example.com, obviously.
Upload the file back to your site, in the same location. FileZilla offers a handy "edit file" function to do all of the above rapidly; if you can use that, do so.
Load the login or admin page a couple of times. The site should come back up.
Another thing that can happen if your site is multilingual is that get_stylesheet_directory_uri is used in a registered string whose translation is still using the previous domain. In that case, search and replace your translations with the new domain.

The page isn’t redirecting properly in Wordpress Multisite

I am migrating my wordpress multisite (http://blogs.xxx.com) to a sub-directory in a new sever(http://blogs-test.xxx.com/blogs). After run wp-admin/install.php, I am having "The page isn't redirecting properly" error in all the pages. I have done these things:
Checked the wp-config.php to make sure the siteurl and home are set
same:http://blogs-test.xxx.com/blogs;
Checked the .htaccess , and it is the same as the previous one;
Deleted all the plugins in both wp-plugin and mu-plugins folder;
Cleared all the cookies in broswer.
Am I missing something else?
Thanks!
Okay, I solved the redirect loop by modifying the wp-config.php. It was about the sub directory for my site. I had to modify these two lines from
define('DOMAIN_CURRENT_SITE', 'blogs.xxx.com/blogs' );
define('PATH_CURRENT_SITE', '/' );
to:
define('DOMAIN_CURRENT_SITE', 'blogs.xxx.com' );
define('PATH_CURRENT_SITE', '/blogs' );
Not sure why, but this solved the redirect loop issue.
Try this if nothing works and thank the guy in the link i give below as he has figured it out
First thing, make sure that at WordPress General settings, you have HTTPS version URL, not HTTP.
You can verify once by checking MySQL database table. If there is HTTP, you may change to HTTPS.
Or if you need very fast solution, simply define HTTPS version URL via wp-config.php
define('FORCE_SSL_ADMIN', true);
// in some setups HTTP_X_FORWARDED_PROTO might contain
// a comma-separated list e.g. http,https
// so check for https existence
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
$_SERVER['HTTPS']='on';
define('WP_HOME','https://example.com');
define('WP_SITEURL','https://example.com');
/* That's all, stop editing! Happy blogging. */
Then try to access, it should work. If it works, better, at last you can use Search/Replace to fix.
Also, one more thing. Make sure you don’t have vice-versa redirection in the .htaccess
#####Ref
https://codex.wordpress.org/Changing_The_Site_URL
https://codex.wordpress.org/Administration_Over_SSL
This is the reference link to thank this guy!
Have you made the changes in the database as well?
For a quick reference, this is a list of the main tables you will need to update with your new domain name:
wp_options > siteurl
wp_options >home
wp_site
wp_sitemeta > siteurl
wp_blogs > domain (change this for all instances that use your old domain)
wp_#_options > siteurl (the “#” refers to the blog ID of additional sites in your network)
wp_#_options > home
wp_#_options > fileupload_url
Read more here: https://premium.wpmudev.org/blog/move-multisite-new-domain
I had the same problem with my new installation and I wasted lots of time trying everything but nothing worked..
I found the solution was rather very simple. In the set up of the multisite you are supposed to replace the htaccess contents with the newly generated content.
If your .htaccess still has the old content for the first site in the multisite the redirects for the secondary sites will never work for obvious reasons!!
Solution is to replace completely the old htaccess content with the new one!

Wordpress, using different theme: Subdomain or Multisite?

In my new job, our main website is using wordpress at www.company.com.
I'm building a company intranet that I'd like to use a different wordpress theme for, and don't want to mess up the main website. I was thinking that I should create a subdomain (i.e. intranet.company.com) and install wordpress there so that I can use a different theme, but now I'm reading about something called Multisite and I'm just super confused as to what I'm supposed to do.
Is it better to go the multisite route, or just create a subdomain and install wordpress there so that I can use a different theme?
Thank you.
multisite network is a collection of sites that all share the same WordPress installation. They can also share plugins and themes.
The individual sites in the network are virtual sites in the sense that they do not have their own directories on your server, although they do have separate directories for media uploads within the shared installation, and they do have separate tables in the database.
for details
http://codex.wordpress.org/Create_A_Network
SO in your case if you can create subdomain. then you can also install new wordpress on your subdomain.
just diff is. you need to upload plugin .theme.. etc all from your new admin.
and yes you can use another theme etc for your subdomain.
Step -1 create addon subdomain
step -2 install new wp on subdomin. and set up database
step -3. uplaod new theme and then use diff theme in subdomain
You can't literally use another theme on the same installation, but "theme" is just an abstraction after all, it can be made of an unlimited number of completely different templates, so... What you CAN do is trick Wordpress into thinking it's the same theme. A bit quirky, but otherwise fairly easy.
Big caveat: If you're looking to install an off-the-shelf theme, it's probably not worth the trouble, most likely some components down the road will break. Another caveat: Urls will become duplicate, so you may want to either properly set up wp-config to account for this, or rewrite them on the fly or maybe just set up canonicals
But if it's something purpose made, or a very simple cleanly-crafted theme or just prototyping, it works nicely.
So you have your fresh subdomain. All you have to do here is create an index.php, with a single line pointing to your main installation:
require ('/your/path/to/wp/wp-blog-header.php' );
Great progress already! At this point, your subdomain mirrors your website.
Now you want to display something else there. Add this to your functions.php:
add_filter( 'template_include', 'subdomain_theme', 99 );
function subdomain_theme( $template ) {
$uri = $_SERVER['SERVER_NAME'];
if (strpos($uri,'yoursubdomain.') !== FALSE) {
$new_template = '/your/path/to/wp/wp-content/themes/your-subdomain-theme/index.php';
if ( '' != $new_template ) {
return $new_template ;
}
}
return $template;
}
And now you have your 'basic theme' up and running!
If you want to use more templates than just index.php, you'll have to rebuild some of the wp template logic. So, create a new file in your theme directory and point to it. The relevant line from above becomes:
$new_template = '/your/path/to/wp/wp-content/themes/your-subdomain-theme/whatever.php';
And inside whatever.php point to each actual template in part:
if(is_single()) {include('/home/standard.wp/wp-content/themes/feeds/single.php');}
elseif (is_home()) { // ... easy from here
And there's your subdomain separate theme running on the same no-multisite wp instance.

Wordpress Multisite and Subdirectory

This sounds so noob. But I'm really new to wordpress. :)
If I create a multisite then create a new site under it, does wordpress automatically create the files? or will I be the one to install wordpress into its subdirectory?
You need to install one copy of WordPress normally first, but it only needs that single copy of all the core files – /wp-admin/, /wp-includes/, /wp-content/ etc. - to run all of the sites.
To add a new site, you just use the Network Admin menu and it puts any site-specific files for each additional site (other than your first one, that is) in numbered subdirectories.
E.g. media Library files, end up in subdirectories of /wp-content/uploads/sites/.
If you haven't already setup multisite, you need this line in your wp-config.php:
define( 'WP_ALLOW_MULTISITE', true );
Further reading:
https://codex.wordpress.org/Create_A_Network
https://codex.wordpress.org/Multisite_Network_Administration
Opinion: I wouldn't recommend multisite for a complete beginner – things can get really confusing even for experienced users. The WordPress install process is very straightforward so if you have good hosting you shouldn't have trouble running separate, individual sites on the same server.

Stop subdomain redirects to main domain in wordpress

I have a website that is build in WordPress.
I want to build the sub-domains for the site according to the states same as "olx.in" do for different cities.
Everything is setup from the code, server and hosting side, but the problem I am facing is that when I type any sub-domain in the URL like "rj.mysite.com" then I there is somewhere somthing written in the wordpress php file, that is redirecting me to the main domain because I made many changes in the .htaccess file but nothing worked out.
I have tried so much but couldn't found the script that is redirecting the sub-domains to the main domain.
Can anybody please tell me that what should be there in the php code of WordPress that is redirecting my sub-domains to the main site?
just found the answer today, hope you've solved it, assuming you have,
what i did for mine was create another wp-config.php file, named it wp-config-sub.php, then in your sub domain, require the wp-config-sub.php file, instead of the wp-config.php file,
require_once '../wp-config-sub.php';
then go back to your wp-config-sub.php file and comment out these lines
/* Multisite */
//define( 'WP_ALLOW_MULTISITE', true );
//define('MULTISITE', true);
//define('SUBDOMAIN_INSTALL', false);
//define('DOMAIN_CURRENT_SITE', 'yoursiteprimaryurl.com');
//define('PATH_CURRENT_SITE', '/');
//define('SITE_ID_CURRENT_SITE', 1);
//define('BLOG_ID_CURRENT_SITE', 1);
hope this will solve your problem. :)
if everything correct in the NS records and the domain redirects
I think you need to login to wordpress and change in the general settings
WordPress Address (URL)
and
Site Address (URL)
to your sub domain or to check your .htaccess file

Resources