I currently have a website that does repairs and web development.

I want to separate the repair section of the website into its own domain name while also keeping the old domain's URLS intact. Since I have many pages generated by views I'm not sure how to go about doing this.

What I was thinking was clone the current site and remove what is unnecessary on the new site.. then the old site would redirect all those links to the new domain.

What is a good solution to such a migration problem?

  • Is the site going to have the same modules, themes, and everything else? Apr 27, 2014 at 3:18
  • yes. its just that on one site it will have only ecommerce related modules as everything else will be disabled. and as for the other site, those things will be disabled. Apr 28, 2014 at 15:04
  • Seems tricky. Just thinking about it logically (without the "how do I do this in Drupal" question yet), how does the "old" site know which pages are going to exist on the new site? Is there something they all have in common?
    – davidcl
    Apr 30, 2014 at 14:48
  • im thinking of just using one of these rewrite rules: stackoverflow.com/questions/4307780/… --- but im not sure which one is appropriate to use. this would solve the issue completely without editing anything in drupal. May 5, 2014 at 22:11

2 Answers 2


If the two websites should be identical but available at separate domains and you use relative URLs throughout your site this is actually quite simple. This is assuming you want all links available at both domains.

Direct the new domain name to point your Drupal install.

Depending on your system configuration there are several ways you may need to do this. If you have a dedicated IP you can simply point your domain to the appropriate IP and ff you use virtual hosts you may need to setup a symbolic link.

ln -s /var/www/example.com /var/www/newdomain.com

All relative URLs should inherit the currently loaded domain name.

I believe for this to work though you will need to leave $base_url commented out in settings.php.

 * Base URL (optional).
 * If you are experiencing issues with different site domains,
 * uncomment the Base URL statement below (remove the leading hash sign)
 * and fill in the URL to your Drupal installation.
 * You might also want to force users to use a given domain.
 * See the .htaccess file for more information.
 * Examples:
 *   $base_url = 'http://www.example.com';
 *   $base_url = 'http://www.example.com:8888';
 *   $base_url = 'http://www.example.com/drupal';
 *   $base_url = 'https://www.example.com:8888/drupal';
 * It is not allowed to have a trailing slash; Drupal will add it
 * for you.
 # $base_url = 'http://www.example.com';  // NO trailing slash!

Using this method I rarely have to make custom edits. This includes views output. Just make sure you always use relative URLs.

If you want the content split up between the sites or want to make change the theme or layout you may need to do something a bit more complex.

There are other more robust and complicated ways to separate out your content. A few modules and concepts that come to mind include...

  • Domain Access
  • Multi-Site (Added for reference, does not meet your requirements.)
  • Virtual Sites (Disclosure: I haven't used this.)
  • Duplicate your sites (As you mentioned in your question)

I will try to update my answer to be more appropriate with your feedback. Feel free to add details about your hosting environment and how and if the content will be split.

  • so the thing is yes i can easily clone the site, but currently the main site has many dynamically generated urls. when i clone the site to the other domain i want these urls to be pointing to the new domain. Also keeping in mind that the main site still has to exists. I am only migrating/cloning the main sites ecommerce aspect of it to the new site and disabling everything else. Here's my site in question: www.xcubicle.com -- so as you can see i have a repair oriented site with products. im just moving those products to a new site while keeping their URLs intact by doing a 301 redirect. thanks Apr 28, 2014 at 15:06

Virtual Hosts:

Edit hosts file -> /etc/hosts and add sitename

<VirtualHost *:80>
ServerAdmin webmaster@localhost
     ServerName sitename
     ServerAlias  sitename-alises
DocumentRoot /var/www/sitename/
<Directory /var/www/sitename/>
    Options FollowSymLinks
    AllowOverride ALL
<Directory /var/www/sitename>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow,deny
    allow from all


Create a .htaccess file with the below code, it will ensure that all your directories and pages of your old domain will get correctly redirected to your new domain. The .htaccess file needs to be placed in the root directory of your old website (i.e the same directory where your index file is placed)

 Options +FollowSymLinks
 RewriteEngine on
 RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

Symbolic link:

Execute below command line

ln -s /var/www/from/directroyname /var/www/to/directoryname

Replace example.sites.php file to sites.php

Edit as your need.

# $sites['devexample.com'] = 'example.com';

# $sites['localhost.example'] = 'example.com';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.