Raza Mehdi's Blog

Archive for September, 2011

How to enable Multisite/Multidomains in WordPress?

by on Sep.12, 2011, under Uncategorized

Hey guys!

I recently worked on a wordpress project, in which i had to enable multiple sites running on a single wordpress installation. Following are steps involved in creating the multi-site on a single wordpress installation:

  • First install wordpress on your machine using virtual host configuration. Suppose, you installed it on the local virtual host with address http://wordpress.localdev/.
  • Edit the wp.config.php and add the following line after /* That’s all, stop editing! Happy blogging. */:
    define('WP_ALLOW_MULTISITE', true);
    
  • Now refresh the wordpress admin page.
  • Again edit the wp.config.phpand add the following lines after /* That’s all, stop editing! Happy blogging. */:
    define( 'MULTISITE', true );
    define( 'SUBDOMAIN_INSTALL', true );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', 'wordpress.localdev' );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );
    
  • Create/Edit the .htaccessfile, and put the following code:
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    
    # uploaded files
    RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
    
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^ - [L]
    RewriteRule . index.php [L]
    
  • Now create the virtual hosts with the address pattern [hostname].wordpress.localdev. All the virtual hosts created using the aforementioned pattern must point to the wordpress installtion folder. Restart apache after this.
  • Now click the link in the top-right column of the admin panel, and select Network Admin. This will bring you in the network admin page:
  • Now click the Sites link in the left-hand column:
  • Now click the link Add New to create a new site:
  • Suppose you created the virtual hosts ads.wordpress.localdev, jobs.wordpress.localdev and coupons.wordpress.localdev. Simply enter ads, jobs and coupons in the site address fields for each site plus the relevant site title and site admin email address.
  • After all sites are created, go to Themes page by clicking the Themes link on the left side:
  • Install any other themes you want. After installing the themes, go to the Themes page to Network enable them.
  • Now click the Site Admin link in the top-right column of the page. This will take you to the main dashboard.
  • Now open a new browser window, and type the virtual host URLs you created above like http://ads.wordpress.localdev/wp-admin to go to admin backend for the respective site. Change the theme by clicking the Appearence link in the left-side column of the admin page. This will change the template for the respective address.
  • When you type in the URL of your virtual host, it will show the frontend with the new active theme for the respective subdomain/virtual host.
  • Also all the users data will be shared across each subdomain setup on wordpress.
Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!