Setup Drupal's multisite feature in Local machine.
For that we have to follow the following three steps.
1. Add alias to our Apache configuration file
2. Redirecting all requests to index.php
3. Creating our settings.php
Add alias to our Apache configuration file
We want requests for the 3 subdirectories(emea, la, uk) to go to the same Drupal instance.We can do this using Apache's Alias functionality.
DocumentRoot “/xampp/htdocs/drupal”
Alias /emea C:/xampp/htdocs/drupal
Alias /la C:/xampp/htdocs/drupal
Alias /uk C:/xampp/htdocs/drupal
I'm supposing here Drupal's codebase is hosted in C:/xampp/htdocs/drupal on your machine
Redirecting all requests to index.php
Now that we're serving all requests from one codebase we have to redirect all requests to index.php. This needs to be done since all Drupal requests are served from one endpoint, called index.php. So we have to do the below changes in the .htaccess file in the same order as mentioned below.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/emea/(.*)$
RewriteRule ^(.*)$ /emea/index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/la/(.*)$
RewriteRule ^(.*)$ /la/index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} ^/emea/(.*)$
RewriteRule ^(.*)$ /uk/index.php?q=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Creating our settings.php
We can now have different settings (database, ...) for each site by creating a different settings file for each site. Place the settings.php for each file under a directory called after the domain name and subdirectory. In our example we would have the following setting files:
C:/xampp/htdocs/drupal/sites/default/settings.php -Base site Settings.php
C:/xampp/htdocs/drupal/sites/localhost.emea/settings.php -EMEA site Settings.php
C:/xampp/htdocs/drupal/sites/localhost.la/settings.php -LA site Settings.php
C:/xampp/htdocs/drupal/sites/localhost.uk/settings.php -UK site Settings.php
Now, start installing the site by using the below URLS
1. http://localhost – Base site
2. http://localhost/emea – EMEA site
3. http://localhost/la – LA site
4. http://localhost/uk – UK site
Enjoy the Drupal's multisite feature in the subdirectories.